rvermeulen
Member
I am getting an error when I attempt to insert a record. Here is my code
It is failing on the line attempting to do the ExecuteNonQuery(). I
noticed that the OleDbCommand object did not recognize the
ExecuteNonQuery method when I typed it. Im assuming that
might have something to do with the problem.
I am a newbie at this and have a question about how Im going
about doing this. I have created a dataset that is bound to a
datagrid. The grid populates fine. I understand, that I should be
able to update/delete those records. However, if I want to insert
a new record into the datagrid, is this the correct way to do it ?
Im going to a new page, allowing the user to enter the
information into a form, and then I have the above code
triggering. Am I doing this correctly?
Does anyone have any thoughts?
I appreciate any advice
Rick
Code:
insert
sql = "insert into EMPLOYEES values (@UserID," + _
txtFirstName.Text + "," + txtLastName.Text + "," + _
txtAddress.Text + "," + txtCity.Text + "," + txtState.Text + "," _
+ txtZipCode.Text + ",#" + txtHireDate.Text + "#," + txtTitle.Text + ")"
Dim func As New CommonFunctions()
Dim cmdIns = New OleDb.OleDbCommand(sql, conn)
Dim parm1 = New OleDb.OleDbParameter("@UserID", OleDbType.Integer)
parm1.value = func.getNextID("EMPLOYEES")
cmdIns.parameters.add(parm1)
conn.Open()
cmdIns.executenonquery()
conn.Close()
cmdIns = Nothing
noticed that the OleDbCommand object did not recognize the
ExecuteNonQuery method when I typed it. Im assuming that
might have something to do with the problem.
I am a newbie at this and have a question about how Im going
about doing this. I have created a dataset that is bound to a
datagrid. The grid populates fine. I understand, that I should be
able to update/delete those records. However, if I want to insert
a new record into the datagrid, is this the correct way to do it ?
Im going to a new page, allowing the user to enter the
information into a form, and then I have the above code
triggering. Am I doing this correctly?
Does anyone have any thoughts?
I appreciate any advice
Rick
Last edited by a moderator: