Adding entry to an SQL DB via ODBC

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am developing a front end for an SQL DB. Every other entry form I have created works, excpet the lastes one. When I try to add a new entry, on the ODBCDataapater.Update line I get the following error.ERROR [HY007] [Microsoft][ODBC SQL Server Driver]Associated statement is not prepared
<<

I have googled the error and looked on MSDN, and I get nothing that helps. Please help ASAP. I Cannot carry on with my develpment until I sort this out.

Thanx
 
That is just the thing, I have copied the code from a working form.

But here it is.

Try
Me.intGatePassNumber = CInt(Me.editGatePassNumber.Text)
Me.dtGatePass = Me.objdsGatePass.Tables("tbl_TSGatePass")

Me.drGatePass = Me.dtGatePass.NewRow
Me.drGatePass("ID") = CInt(Me.editGatePassNumber.Text)
Me.drGatePass("PermissionTo") = Me.editPermissionTo.Text
Me.drGatePass("Company") = Me.editCompany.Text
Me.drGatePass("DateTaken") = Me.editDateTaken.Value
Me.drGatePass("DateReturning") = Me.editDateReturning.Text
Me.drGatePass("NotReturning") = Me.chkNotReturning.Checked
Me.drGatePass("AuthorisedBy") = Me.editAuthorisedBy.Text
Me.dtGatePass.Rows.Add(Me.drGatePass)

Me.odbcdaGatePassEntry.Update(Me.objdsGatePass.tbl_TSGatePass)
MsgBox("Entry added!")

Catch ex As Exception
CType(Me.MdiParent, frmMDI).dspConsoleTechnicalServices.Text = CType(Me.MdiParent, frmMDI).dspConsoleTechnicalServices.Text & vbCrLf & ex.Message
End Try

Jonathan Allen said:
It would help to see more of your code.

--
Jonathan Allen


Vexander said:
I am developing a front end for an SQL DB. Every other entry form I have created works, excpet the lastes one. When I try to add a new entry, on the ODBCDataapater.Update line I get the following error.ERROR [HY007] [Microsoft][ODBC SQL Server Driver]Associated statement is not prepared
<<

I have googled the error and looked on MSDN, and I get nothing that helps. Please help ASAP. I Cannot carry on with my develpment until I sort this out.

Thanx
 
Try
Me.intGatePassNumber = CInt(Me.editGatePassNumber.Text)
Me.dtGatePass = Me.objdsGatePass.Tables("tbl_TSGatePass")

Me.drGatePass = Me.dtGatePass.NewRow
Me.drGatePass("ID") = CInt(Me.editGatePassNumber.Text)
Me.drGatePass("PermissionTo") = Me.editPermissionTo.Text
Me.drGatePass("Company") = Me.editCompany.Text
Me.drGatePass("DateTaken") = Me.editDateTaken.Value
Me.drGatePass("DateReturning") = Me.editDateReturning.Text
Me.drGatePass("NotReturning") = Me.chkNotReturning.Checked
Me.drGatePass("AuthorisedBy") = Me.editAuthorisedBy.Text
Me.dtGatePass.Rows.Add(Me.drGatePass)

Me.odbcdaGatePassEntry.Update(Me.objdsGatePass.tbl_TSGatePass)
MsgBox("Entry added!")

Catch ex As Exception
CType(Me.MdiParent, frmMDI).dspConsoleTechnicalServices.Text = CType(Me.MdiParent, frmMDI).dspConsoleTechnicalServices.Text & vbCrLf & ex.Message
End Try


Jonathan Allen said:
It would help to see more of your code.

--
Jonathan Allen


Vexander said:
I am developing a front end for an SQL DB. Every other entry form I have created works, excpet the lastes one. When I try to add a new entry, on the ODBCDataapater.Update line I get the following error.ERROR [HY007] [Microsoft][ODBC SQL Server Driver]Associated statement is not prepared
<<

I have googled the error and looked on MSDN, and I get nothing that helps. Please help ASAP. I Cannot carry on with my develpment until I sort this out.

Thanx
 
That is just the thing, I have copied the code from a working form.

Check to see that dtGatePass is being setup in exactly the same way as it was in the form you copied it from. That means looking at the all properties one by one, and the order in which they are set. I don't normally use dataTables, so I cannot tell you what to look for.

--
Jonathan Allen


Vexander said:
That is just the thing, I have copied the code from a working form.

But here it is.

Try
Me.intGatePassNumber = CInt(Me.editGatePassNumber.Text)
Me.dtGatePass = Me.objdsGatePass.Tables("tbl_TSGatePass")

Me.drGatePass = Me.dtGatePass.NewRow
Me.drGatePass("ID") = CInt(Me.editGatePassNumber.Text)
Me.drGatePass("PermissionTo") = Me.editPermissionTo.Text
Me.drGatePass("Company") = Me.editCompany.Text
Me.drGatePass("DateTaken") = Me.editDateTaken.Value
Me.drGatePass("DateReturning") = Me.editDateReturning.Text
Me.drGatePass("NotReturning") = Me.chkNotReturning.Checked
Me.drGatePass("AuthorisedBy") = Me.editAuthorisedBy.Text
Me.dtGatePass.Rows.Add(Me.drGatePass)

Me.odbcdaGatePassEntry.Update(Me.objdsGatePass.tbl_TSGatePass)
MsgBox("Entry added!")

Catch ex As Exception
CType(Me.MdiParent, frmMDI).dspConsoleTechnicalServices.Text = CType(Me.MdiParent, frmMDI).dspConsoleTechnicalServices.Text & vbCrLf & ex.Message
End Try

Jonathan Allen said:
It would help to see more of your code.

--
Jonathan Allen


Vexander said:
I am developing a front end for an SQL DB. Every other entry form I have created works, excpet the lastes one. When I try to add a new entry, on the ODBCDataapater.Update line I get the following error.

ERROR [HY007] [Microsoft][ODBC SQL Server Driver]Associated statement is not prepared
<<

I have googled the error and looked on MSDN, and I get nothing that helps. Please help ASAP. I Cannot carry on with my develpment until I sort this out.

Thanx
 
Back
Top