SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict jlisec01's Avatar
    Join Date
    Nov 2006
    Location
    MI
    Posts
    331
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    inserting records into database error

    Hi there, I'm trying to insert record into my database, but I get an error that says Operation must use an updateable query, I'm using IIS 6, any help? thanks.

    Code VBNET:
    <%@ Import Namespace="System.Data.OleDb" %>
     
    <html>
    <head>
    <title>Insert Student</title>
    <script runat="server" language="VB">
       Dim objConn As New OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;Data Source=" &server.mappath("CollegeDB.mdb"))
       Dim objCmd As OleDbCommand
       Dim objRdr As OleDbDataReader
     
    Sub SubmitStudent(s As Object, e As EventArgs)
        objCmd = New OleDbCommand("INSERT INTO STUDENT (STUDENT_ID, FIRST_NAME, LAST_NAME, STUDENT_GENDER, DATE_OF_BIRTH, STREET_ADDRESS, CITY, STATE, ZIP, PHONE) VALUES (@STUDENT_ID, @FIRST_NAME, @LAST_NAME, @STUDENT_GENDER, @DATE_OF_BIRTH, @STREET_ADDRESS, @CITY, @STATE, @ZIP, @PHONE)", objConn)
        objCmd.Parameters.Add("@STUDENT_ID", 5)
        objCmd.Parameters.Add("@FIRST_NAME", txtFirstName.Text)
        objCmd.Parameters.Add("@LAST_NAME", txtLastName.Text)
        objCmd.Parameters.Add("@STUDENT_GENDER", txtGender.Text)
        objCmd.Parameters.Add("@DATE_OF_BIRTH", txtDOB.Text)
        objCmd.Parameters.Add("@STREET_ADDRESS", txtAddress.Text)
        objCmd.Parameters.Add("@CITY", txtCity.Text)
        objCmd.Parameters.Add("@STATE", txtState.Text)
        objCmd.Parameters.Add("@ZIP", txtZip.Text)
        objCmd.Parameters.Add("@PHONE", txtPhone.Text)
        objConn.Open()
        objCmd.ExecuteNonQuery()
        objConn.Close()
    End Sub
    </script>
    </head>
    <body>
    <form runat="server">
    <table width="100%" border="0" cellspacing="0" cellpadding="10">
      <tr>
        <td valign="top">
          <h1>Insert Student</h1>
          <p>First Name: <asp:TextBox id="txtFirstName" CssClass="textbox" runat="server" /><br />
          Last Name: <asp:TextBox id="txtLastName" CssClass="textbox" runat="server" /><br />
          Gender: <asp:TextBox id="txtGender" CssClass="textbox" runat="server" /></p>
          Date of Birth: <asp:TextBox id="txtDOB" CssClass="textbox" runat="server" /><br />
          Address: <asp:TextBox id="txtAddress" CssClass="textbox" runat="server" /><br />
          City: <asp:TextBox id="txtCity" CssClass="textbox" runat="server" /><br />
          State: <asp:TextBox id="txtState" CssClass="textbox" runat="server" /><br />
          Zip: <asp:TextBox id="txtZip" CssClass="textbox" runat="server" /><br />
          Phone: <asp:TextBox id="txtPhone" CssClass="textbox" runat="server" /></p>
     
          <p><asp:Button id="btnSubmit" CssClass="button" Text="Submit Request" OnClick="SubmitStudent" runat="server" /></p>
        </td>
      </tr>
    </table>
     
    </form>
    </body>
    </html>

  2. #2
    SitePoint Wizard rbutler's Avatar
    Join Date
    Jul 2003
    Location
    Springfield, MO
    Posts
    1,867
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I answered you in your first thread.
    Ryan Butler

    Midwest Web Design


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •