473,849 Members | 1,811 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error 07002 SQLBindParamete r not used for all parameters

Hi, I created a simple VB.NET 2003 application through Visual Studio
that connects to a MySQL database and loads a table into a Dataset, and
then displays that table information in a DataGrid on a form for
editing. The table fill works fine, the delete function works fine, but
when I try to update a row, the application fails with the following
error message:

An unhandled exception of type 'System.Data.Od bc.OdbcExceptio n' occurred
in system.data.dll

Additional information: System error.

'Data Access VB App.exe': Loaded
'c:\windows\ass embly\gac\micro soft.visualbasi c\7.0.5000.0__b 03f5f7f11d50
a3a\microsoft.v isualbasic.dll' , No symbols loaded.

Unhandled Exception: System.Data.Odb c.OdbcException : ERROR [07002]
[MySQL][ODBC 3.51 Driver][mysqld-4.0.21-debug]SQLBindParamete r not used
for all parameters
at System.Data.Com mon.DbDataAdapt er.Update(DataR ow[] dataRows,
DataTableMappin g tableMapping)
at System.Data.Com mon.DbDataAdapt er.Update(DataS et dataSet, String
srcTable)
at System.Data.Com mon.DbDataAdapt er.Update(DataS et dataSet)
at Data_Access_VB_ App.Form1.btnUp date_Click(Obje ct sender, EventArgs
e) in C:\Documents and Settings\System Admin\My Documents\Visua l Studio
Projects\Data Access VB App\Form1.vb:li ne 225
at System.Windows. Forms.Control.O nClick(EventArg s e)
at System.Windows. Forms.Button.On Click(EventArgs e)
at System.Windows. Forms.Button.On MouseUp(MouseEv entArgs mevent)
at System.Windows. Forms.Control.W mMouseUp(Messag e& m, MouseButtons
button, Int32 clicks)
at System.Windows. Forms.Control.W ndProc(Message& m)
at System.Windows. Forms.ButtonBas e.WndProc(Messa ge& m)
at System.Windows. Forms.Button.Wn dProThe program '[2608] Data Access
VB App.exe' has exited with code 0 (0x0).
c(Message& m)
at System.Windows. Forms.ControlNa tiveWindow.OnMe ssage(Message& m)
at System.Windows. Forms.ControlNa tiveWindow.WndP roc(Message& m)
at System.Windows. Forms.NativeWin dow.DebuggableC allback(IntPtr hWnd,
Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows. Forms.UnsafeNat iveMethods.Disp atchMessageW(MS G&
msg)
at
System.Windows. Forms.Component Manager.System. Windows.Forms.U nsafeNativeM
ethods+IMsoComp onentManager.FP ushMessageLoop( Int32 dwComponentID, Int32
reason, Int32 pvLoopData)
at System.Windows. Forms.ThreadCon text.RunMessage LoopInner(Int32
reason, ApplicationCont ext context)
at System.Windows. Forms.ThreadCon text.RunMessage Loop(Int32 reason,
ApplicationCont ext context)
at System.Windows. Forms.Applicati on.Run(Form mainForm)
at Data_Access_VB_ App.Form1.Main( ) in C:\Documents and
Settings\System Admin\My Documents\Visua l Studio Projects\Data Access VB
App\Form1.vb:li ne 1
The majority of the code was generated by Visual Studio and based on the
error message it would seem that I have to add SQLBindParamete r
statements, but I am not sure the syntax that I should be using. I am
new to VB.NET (coming from Java/J2EE) and haven't been able to come up
with a workable solution after pouring over the MSDN manuals. Here is
the generated code:
Public Class Form1
Inherits System.Windows. Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeCompo nent()

'Add any initialization after the InitializeCompo nent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As
Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Disp ose()
End If
End If
MyBase.Dispose( disposing)
End Sub
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents OdbcDataAdapter 1 As
System.Data.Odb c.OdbcDataAdapt er
Friend WithEvents OdbcConnection1 As System.Data.Odb c.OdbcConnectio n
Friend WithEvents DsTags1 As Data_Access_VB_ App.dsTags
Friend WithEvents DataGrid1 As System.Windows. Forms.DataGrid
Friend WithEvents btnUpdate As System.Windows. Forms.Button
Friend WithEvents btnLoad As System.Windows. Forms.Button
Friend WithEvents OdbcDataAdapter 2 As
System.Data.Odb c.OdbcDataAdapt er
Friend WithEvents OdbcSelectComma nd2 As System.Data.Odb c.OdbcCommand
Friend WithEvents OdbcInsertComma nd2 As System.Data.Odb c.OdbcCommand
Friend WithEvents OdbcConnection2 As System.Data.Odb c.OdbcConnectio n
Friend WithEvents OdbcDeleteComma nd2 As System.Data.Odb c.OdbcCommand
Friend WithEvents OdbcUpdateComma nd2 As System.Data.Odb c.OdbcCommand
Friend WithEvents OdbcSelectComma nd1 As System.Data.Odb c.OdbcCommand
Friend WithEvents OdbcInsertComma nd1 As System.Data.Odb c.OdbcCommand
Friend WithEvents OdbcDeleteComma nd1 As System.Data.Odb c.OdbcCommand
Friend WithEvents OdbcUpdateComma nd1 As System.Data.Odb c.OdbcCommand
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()
Me.OdbcDataAdap ter1 = New System.Data.Odb c.OdbcDataAdapt er
Me.OdbcConnecti on1 = New System.Data.Odb c.OdbcConnectio n
Me.DsTags1 = New Data_Access_VB_ App.dsTags
Me.DataGrid1 = New System.Windows. Forms.DataGrid
Me.btnUpdate = New System.Windows. Forms.Button
Me.btnLoad = New System.Windows. Forms.Button
Me.OdbcDataAdap ter2 = New System.Data.Odb c.OdbcDataAdapt er
Me.OdbcDeleteCo mmand2 = New System.Data.Odb c.OdbcCommand
Me.OdbcConnecti on2 = New System.Data.Odb c.OdbcConnectio n
Me.OdbcInsertCo mmand2 = New System.Data.Odb c.OdbcCommand
Me.OdbcSelectCo mmand2 = New System.Data.Odb c.OdbcCommand
Me.OdbcUpdateCo mmand2 = New System.Data.Odb c.OdbcCommand
Me.OdbcSelectCo mmand1 = New System.Data.Odb c.OdbcCommand
Me.OdbcInsertCo mmand1 = New System.Data.Odb c.OdbcCommand
Me.OdbcDeleteCo mmand1 = New System.Data.Odb c.OdbcCommand
Me.OdbcUpdateCo mmand1 = New System.Data.Odb c.OdbcCommand
CType(Me.DsTags 1,
System.Componen tModel.ISupport Initialize).Beg inInit()
CType(Me.DataGr id1,
System.Componen tModel.ISupport Initialize).Beg inInit()
Me.SuspendLayou t()
'
'OdbcDataAdapte r1
'
Me.OdbcDataAdap ter1.DeleteComm and = Me.OdbcDeleteCo mmand1
Me.OdbcDataAdap ter1.InsertComm and = Me.OdbcInsertCo mmand1
Me.OdbcDataAdap ter1.SelectComm and = Me.OdbcSelectCo mmand1
Me.OdbcDataAdap ter1.TableMappi ngs.AddRange(Ne w
System.Data.Com mon.DataTableMa pping() {New
System.Data.Com mon.DataTableMa pping("Table", "epctag", New
System.Data.Com mon.DataColumnM apping() {New
System.Data.Com mon.DataColumnM apping("ID", "ID"), New
System.Data.Com mon.DataColumnM apping("OBJECT_ EPC", "OBJECT_EPC "), New
System.Data.Com mon.DataColumnM apping("READER_ EPC", "READER_EPC "), New
System.Data.Com mon.DataColumnM apping("DATE_TI ME", "DATE_TIME" ), New
System.Data.Com mon.DataColumnM apping("PAYLOAD ", "PAYLOAD"), New
System.Data.Com mon.DataColumnM apping("GTIN_DO MAIN", "GTIN_DOMAI N"), New
System.Data.Com mon.DataColumnM apping("GTIN_CL ASS", "GTIN_CLASS")}) })
Me.OdbcDataAdap ter1.UpdateComm and = Me.OdbcUpdateCo mmand1
'
'OdbcConnection 1
'
Me.OdbcConnecti on1.ConnectionS tring =
"STMT=;OPTION=3 ;DSN=EPCThingsN ET;UID=root;SOC KET=;DESC=MySQL ODBC 3.51
Driver DSN;" & _
"DATABASE=thing snet;SERVER=loc alhost;PORT=330 6"
'
'DsTags1
'
Me.DsTags1.Data SetName = "dsTags"
Me.DsTags1.Loca le = New
System.Globaliz ation.CultureIn fo("en-US")
'
'DataGrid1
'
Me.DataGrid1.Da taMember = "epctag"
Me.DataGrid1.Da taSource = Me.DsTags1
Me.DataGrid1.He aderForeColor =
System.Drawing. SystemColors.Co ntrolText
Me.DataGrid1.Lo cation = New System.Drawing. Point(8, 128)
Me.DataGrid1.Na me = "DataGrid1"
Me.DataGrid1.Si ze = New System.Drawing. Size(584, 264)
Me.DataGrid1.Ta bIndex = 0
'
'btnUpdate
'
Me.btnUpdate.Lo cation = New System.Drawing. Point(224, 48)
Me.btnUpdate.Na me = "btnUpdate"
Me.btnUpdate.Si ze = New System.Drawing. Size(152, 23)
Me.btnUpdate.Ta bIndex = 1
Me.btnUpdate.Te xt = "Save Changes in Database"
'
'btnLoad
'
Me.btnLoad.Loca tion = New System.Drawing. Point(56, 40)
Me.btnLoad.Name = "btnLoad"
Me.btnLoad.TabI ndex = 2
Me.btnLoad.Text = "Load Data"
'
'OdbcSelectComm and1
'
Me.OdbcSelectCo mmand1.CommandT ext = "SELECT ID, OBJECT_EPC,
READER_EPC, DATE_TIME, PAYLOAD, GTIN_DOMAIN, GTIN_CLASS FR" & _
"OM epctag"
Me.OdbcSelectCo mmand1.Connecti on = Me.OdbcConnecti on1
'
'OdbcInsertComm and1
'
Me.OdbcInsertCo mmand1.CommandT ext = "INSERT INTO epctag(ID,
OBJECT_EPC, READER_EPC, DATE_TIME, PAYLOAD, GTIN_DOMAIN, G" & _
"TIN_CLASS) VALUES (?, ?, ?, ?, ?, ?, ?)"
Me.OdbcInsertCo mmand1.Connecti on = Me.OdbcConnecti on1
Me.OdbcInsertCo mmand1.Paramete rs.Add(New
System.Data.Odb c.OdbcParameter ("ID", System.Data.Odb c.OdbcType.BigI nt,
0, "ID"))
Me.OdbcInsertCo mmand1.Paramete rs.Add(New
System.Data.Odb c.OdbcParameter ("OBJECT_EPC ",
System.Data.Odb c.OdbcType.VarC har, 255, "OBJECT_EPC "))
Me.OdbcInsertCo mmand1.Paramete rs.Add(New
System.Data.Odb c.OdbcParameter ("READER_EPC ",
System.Data.Odb c.OdbcType.VarC har, 255, "READER_EPC "))
Me.OdbcInsertCo mmand1.Paramete rs.Add(New
System.Data.Odb c.OdbcParameter ("DATE_TIME" ,
System.Data.Odb c.OdbcType.VarC har, 255, "DATE_TIME" ))
Me.OdbcInsertCo mmand1.Paramete rs.Add(New
System.Data.Odb c.OdbcParameter ("PAYLOAD",
System.Data.Odb c.OdbcType.VarC har, 255, "PAYLOAD"))
Me.OdbcInsertCo mmand1.Paramete rs.Add(New
System.Data.Odb c.OdbcParameter ("GTIN_DOMAI N",
System.Data.Odb c.OdbcType.VarC har, 255, "GTIN_DOMAI N"))
Me.OdbcInsertCo mmand1.Paramete rs.Add(New
System.Data.Odb c.OdbcParameter ("GTIN_CLASS ",
System.Data.Odb c.OdbcType.VarC har, 255, "GTIN_CLASS "))
'
'OdbcDeleteComm and1
'
Me.OdbcDeleteCo mmand1.CommandT ext = "DELETE FROM epctag WHERE
(ID = ?)"
Me.OdbcDeleteCo mmand1.Connecti on = Me.OdbcConnecti on1
Me.OdbcDeleteCo mmand1.Paramete rs.Add(New
System.Data.Odb c.OdbcParameter ("ID", System.Data.Odb c.OdbcType.BigI nt,
0, System.Data.Par ameterDirection .Input, False, CType(0, Byte), CType(0,
Byte), "ID", System.Data.Dat aRowVersion.Ori ginal, Nothing))
'
'OdbcUpdateComm and1
'
Me.OdbcUpdateCo mmand1.CommandT ext = "UPDATE ecptag SET ID = ?,
OBJECT_EPC = ?, READER_EPC = ?, DATE_TIME = ?, PAYLOAD " & _
"= ?, GTIN_DOMAIN = ?, GTIN_CLASS = ? WHERE (ID = ?)"
Me.OdbcUpdateCo mmand1.Connecti on = Me.OdbcConnecti on1
Me.OdbcUpdateCo mmand1.Paramete rs.Add(New
System.Data.Odb c.OdbcParameter ("ID", System.Data.Odb c.OdbcType.BigI nt,
0, "ID"))
Me.OdbcUpdateCo mmand1.Paramete rs.Add(New
System.Data.Odb c.OdbcParameter ("OBJECT_EPC ",
System.Data.Odb c.OdbcType.VarC har, 255, "OBJECT_EPC "))
Me.OdbcUpdateCo mmand1.Paramete rs.Add(New
System.Data.Odb c.OdbcParameter ("READER_EPC ",
System.Data.Odb c.OdbcType.VarC har, 255, "READER_EPC "))
Me.OdbcUpdateCo mmand1.Paramete rs.Add(New
System.Data.Odb c.OdbcParameter ("DATE_TIME" ,
System.Data.Odb c.OdbcType.VarC har, 255, "DATE_TIME" ))
Me.OdbcUpdateCo mmand1.Paramete rs.Add(New
System.Data.Odb c.OdbcParameter ("PAYLOAD",
System.Data.Odb c.OdbcType.VarC har, 255, "PAYLOAD"))
Me.OdbcUpdateCo mmand1.Paramete rs.Add(New
System.Data.Odb c.OdbcParameter ("GTIN_DOMAI N",
System.Data.Odb c.OdbcType.VarC har, 255, "GTIN_DOMAI N"))
Me.OdbcUpdateCo mmand1.Paramete rs.Add(New
System.Data.Odb c.OdbcParameter ("GTIN_CLASS ",
System.Data.Odb c.OdbcType.VarC har, 255, "GTIN_CLASS "))
'
'Form1
'
Me.AutoScaleBas eSize = New System.Drawing. Size(5, 13)
Me.ClientSize = New System.Drawing. Size(608, 398)
Me.Controls.Add (Me.btnLoad)
Me.Controls.Add (Me.btnUpdate)
Me.Controls.Add (Me.DataGrid1)
Me.Name = "Form1"
Me.Text = "Form1"
CType(Me.DsTags 1,
System.Componen tModel.ISupport Initialize).End Init()
CType(Me.DataGr id1,
System.Componen tModel.ISupport Initialize).End Init()
Me.ResumeLayout (False)

End Sub

#End Region

Private Sub btnUpdate_Click (ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles btnUpdate.Click
OdbcDataAdapter 1.Update(DsTags 1)
MessageBox.Show ("Database Updated!")
End Sub

Private Sub btnLoad_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles btnLoad.Click
OdbcDataAdapter 1.Fill(DsTags1)
MessageBox.Show ("Data Table Loaded Successfully!")
End Sub
End Class
That's the long and short of it! Appreciate any help.


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #1
1 8850
S G
Take a careful look at your SQL statement for the update. You'llnotice that there are *8* parameters (indicated by '?') in theupdate statement. Your code only create OdbcParameters for thefirst seven. The eighth is the value of 'ID' for the row you'reupdating, and it needs a parameter too...

Steve G.
------------------------------------------------------------------------------------
Hi, I created a simple VB.NET 2003 application through VisualStudio
that connects to a MySQL database and loads a table into aDataset, and
then displays that table information in a DataGrid on a formfor
editing. The table fill works fine, the delete function worksfine, but
when I try to update a row, the application fails with thefollowing
error message:

An unhandled exception of type 'System.Data.Od bc.OdbcExceptio n'occurred
in system.data.dll

Additional information: System error.

'Data Access VB App.exe': Loaded
'c:\windows\as sembly\gac\micr osoft.visualbas ic\7.0.5000.0__ b03f5f7f11d50
a3a\microsoft.v isualbasic.dll' , No symbols loaded.

Unhandled Exception: System.Data.Odb c.OdbcException : ERROR[07002]
[MySQL][ODBC 3.51 Driver][mysqld-4.0.21-debug]SQLBindParamete rnot used
for all parameters
at System.Data.Com mon.DbDataAdapt er.Update(DataR ow[]dataRows,
DataTableMappin g tableMapping)
at System.Data.Com mon.DbDataAdapt er.Update(DataS et dataSet,String
srcTable)
at System.Data.Com mon.DbDataAdapt er.Update(DataS et dataSet)
at Data_Access_VB_ App.Form1.btnUp date_Click(Obje ct sender,EventArg s
e) in C:\Documents and Settings\System Admin\MyDocumen ts\Visual Studio
Projects\Data Access VB App\Form1.vb:li ne 225
at System.Windows. Forms.Control.O nClick(EventArg s e)
at System.Windows. Forms.Button.On Click(EventArgs e)
at System.Windows. Forms.Button.On MouseUp(MouseEv entArgsmevent)
at System.Windows. Forms.Control.W mMouseUp(Messag e& m,MouseButtons
button, Int32 clicks)
at System.Windows. Forms.Control.W ndProc(Message& m)
at System.Windows. Forms.ButtonBas e.WndProc(Messa ge& m)
at System.Windows. Forms.Button.Wn dProThe program '[2608]Data Access
VB App.exe' has exited with code 0 (0x0).
c(Message& m)
atSystem.Window s.Forms.Control NativeWindow.On Message(Message & m)
at System.Windows. Forms.ControlNa tiveWindow.WndP roc(Message&m)
atSystem.Window s.Forms.NativeW indow.Debuggabl eCallback(IntPt rhWnd,
Int32 msg, IntPtr wparam, IntPtr lparam)
atSystem.Window s.Forms.UnsafeN ativeMethods.Di spatchMessageW( MSG&
msg)
at
System.Windows .Forms.Componen tManager.System .Windows.Forms. UnsafeNativeM
ethods+IMsoComp onentManager.FP ushMessageLoop( Int32dwComponen tID, Int32
reason, Int32 pvLoopData)
atSystem.Window s.Forms.ThreadC ontext.RunMessa geLoopInner(Int 32
reason, ApplicationCont ext context)
at System.Windows. Forms.ThreadCon text.RunMessage Loop(Int32reaso n,
ApplicationCont ext context)
at System.Windows. Forms.Applicati on.Run(Form mainForm)
at Data_Access_VB_ App.Form1.Main( ) in C:\Documents and
Settings\System Admin\My Documents\Visua l Studio Projects\DataAc cess VB
App\Form1.vb:li ne 1
The majority of the code was generated by Visual Studio andbased on the
error message it would seem that I have to addSQLBindParam eter
statements, but I am not sure the syntax that I should beusing. I am
new to VB.NET (coming from Java/J2EE) and haven't been able tocome up
with a workable solution after pouring over the MSDN manuals. Here is
the generated code:
Public Class Form1
Inherits System.Windows. Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeCompo nent()

'Add any initialization after the InitializeCompo nent()call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposingAs
Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Disp ose()
End If
End If
MyBase.Dispose( disposing)
End Sub
'NOTE: The following procedure is required by the Windows FormDesigner
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents OdbcDataAdapter 1 As
System.Data.Odb c.OdbcDataAdapt er
Friend WithEvents OdbcConnection1 AsSystem.Data.O dbc.OdbcConnect ion
Friend WithEvents DsTags1 As Data_Access_VB_ App.dsTags
Friend WithEvents DataGrid1 AsSystem.Window s.Forms.DataGri d
Friend WithEvents btnUpdate As System.Windows. Forms.Button
Friend WithEvents btnLoad As System.Windows. Forms.Button
Friend WithEvents OdbcDataAdapter 2 As
System.Data.Odb c.OdbcDataAdapt er
Friend WithEvents OdbcSelectComma nd2 AsSystem.Data.O dbc.OdbcCommand
Friend WithEvents OdbcInsertComma nd2 AsSystem.Data.O dbc.OdbcCommand
Friend WithEvents OdbcConnection2 AsSystem.Data.O dbc.OdbcConnect ion
Friend WithEvents OdbcDeleteComma nd2 AsSystem.Data.O dbc.OdbcCommand
Friend WithEvents OdbcUpdateComma nd2 AsSystem.Data.O dbc.OdbcCommand
Friend WithEvents OdbcSelectComma nd1 AsSystem.Data.O dbc.OdbcCommand
Friend WithEvents OdbcInsertComma nd1 AsSystem.Data.O dbc.OdbcCommand
Friend WithEvents OdbcDeleteComma nd1 AsSystem.Data.O dbc.OdbcCommand
Friend WithEvents OdbcUpdateComma nd1 AsSystem.Data.O dbc.OdbcCommand
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()
Me.OdbcDataAdap ter1 = NewSystem.Data. Odbc.OdbcDataAd apter
Me.OdbcConnecti on1 = NewSystem.Data. Odbc.OdbcConnec tion
Me.DsTags1 = New Data_Access_VB_ App.dsTags
Me.DataGrid1 = New System.Windows. Forms.DataGrid
Me.btnUpdate = New System.Windows. Forms.Button
Me.btnLoad = New System.Windows. Forms.Button
Me.OdbcDataAdap ter2 = NewSystem.Data. Odbc.OdbcDataAd apter
Me.OdbcDeleteCo mmand2 = NewSystem.Data. Odbc.OdbcComman d
Me.OdbcConnecti on2 = NewSystem.Data. Odbc.OdbcConnec tion
Me.OdbcInsertCo mmand2 = NewSystem.Data. Odbc.OdbcComman d
Me.OdbcSelectCo mmand2 = NewSystem.Data. Odbc.OdbcComman d
Me.OdbcUpdateCo mmand2 = NewSystem.Data. Odbc.OdbcComman d
Me.OdbcSelectCo mmand1 = NewSystem.Data. Odbc.OdbcComman d
Me.OdbcInsertCo mmand1 = NewSystem.Data. Odbc.OdbcComman d
Me.OdbcDeleteCo mmand1 = NewSystem.Data. Odbc.OdbcComman d
Me.OdbcUpdateCo mmand1 = NewSystem.Data. Odbc.OdbcComman d
CType(Me.DsTags 1,
System.Componen tModel.ISupport Initialize).Beg inInit()
CType(Me.DataGr id1,
System.Componen tModel.ISupport Initialize).Beg inInit()
Me.SuspendLayou t()
'
'OdbcDataAdapte r1
'
Me.OdbcDataAdap ter1.DeleteComm and =Me.OdbcDeleteC ommand1
Me.OdbcDataAdap ter1.InsertComm and =Me.OdbcInsertC ommand1
Me.OdbcDataAdap ter1.SelectComm and =Me.OdbcSelectC ommand1
Me.OdbcDataAdap ter1.TableMappi ngs.AddRange(Ne w
System.Data.Com mon.DataTableMa pping() {New
System.Data.Com mon.DataTableMa pping("Table", "epctag", New
System.Data.Com mon.DataColumnM apping() {New
System.Data.Com mon.DataColumnM apping("ID", "ID"), New
System.Data.Com mon.DataColumnM apping("OBJECT_ EPC","OBJECT_EP C"), New
System.Data.Com mon.DataColumnM apping("READER_ EPC","READER_EP C"), New
System.Data.Com mon.DataColumnM apping("DATE_TI ME", "DATE_TIME"),Ne w
System.Data.Com mon.DataColumnM apping("PAYLOAD ", "PAYLOAD"), New
System.Data.Com mon.DataColumnM apping("GTIN_DO MAIN","GTIN_DOM AIN"), New
System.Data.Com mon.DataColumnM apping("GTIN_CL ASS","GTIN_CLAS S")})})
Me.OdbcDataAdap ter1.UpdateComm and =Me.OdbcUpdateC ommand1
'
'OdbcConnection 1
'
Me.OdbcConnecti on1.ConnectionS tring =
"STMT=;OPTION=3 ;DSN=EPCThingsN ET;UID=root;SOC KET=;DESC=MySQL ODBC 3.51
Driver DSN;" & _
"DATABASE=thing snet;SERVER=loc alhost;PORT=330 6"
'
'DsTags1
'
Me.DsTags1.Data SetName = "dsTags"
Me.DsTags1.Loca le = New
System.Globaliz ation.CultureIn fo("en-US")
'
'DataGrid1
'
Me.DataGrid1.Da taMember = "epctag"
Me.DataGrid1.Da taSource = Me.DsTags1
Me.DataGrid1.He aderForeColor =
System.Drawing. SystemColors.Co ntrolText
Me.DataGrid1.Lo cation = New System.Drawing. Point(8,128)
Me.DataGrid1.Na me = "DataGrid1"
Me.DataGrid1.Si ze = New System.Drawing. Size(584, 264)
Me.DataGrid1.Ta bIndex = 0
'
'btnUpdate
'
Me.btnUpdate.Lo cation = New System.Drawing. Point(224,48)
Me.btnUpdate.Na me = "btnUpdate"
Me.btnUpdate.Si ze = New System.Drawing. Size(152, 23)
Me.btnUpdate.Ta bIndex = 1
Me.btnUpdate.Te xt = "Save Changes in Database"
'
'btnLoad
'
Me.btnLoad.Loca tion = New System.Drawing. Point(56, 40)
Me.btnLoad.Name = "btnLoad"
Me.btnLoad.TabI ndex = 2
Me.btnLoad.Text = "Load Data"
'
'OdbcSelectComm and1
'
Me.OdbcSelectCo mmand1.CommandT ext = "SELECT ID,OBJECT_EPC,
READER_EPC, DATE_TIME, PAYLOAD, GTIN_DOMAIN, GTIN_CLASS FR" &_
"OM epctag"
Me.OdbcSelectCo mmand1.Connecti on = Me.OdbcConnecti on1
'
'OdbcInsertComm and1
'
Me.OdbcInsertCo mmand1.CommandT ext = "INSERT INTOepctag(ID,
OBJECT_EPC, READER_EPC, DATE_TIME, PAYLOAD, GTIN_DOMAIN, G" &_
"TIN_CLASS) VALUES (?, ?, ?, ?, ?, ?, ?)"
Me.OdbcInsertCo mmand1.Connecti on = Me.OdbcConnecti on1
Me.OdbcInsertCo mmand1.Paramete rs.Add(New
System.Data.Odb c.OdbcParameter ("ID",System.Da ta.Odbc.OdbcTyp e.BigInt,
0, "ID"))
Me.OdbcInsertCo mmand1.Paramete rs.Add(New
System.Data.Odb c.OdbcParameter ("OBJECT_EPC ",
System.Data.Odb c.OdbcType.VarC har, 255, "OBJECT_EPC "))
Me.OdbcInsertCo mmand1.Paramete rs.Add(New
System.Data.Odb c.OdbcParameter ("READER_EPC ",
System.Data.Odb c.OdbcType.VarC har, 255, "READER_EPC "))
Me.OdbcInsertCo mmand1.Paramete rs.Add(New
System.Data.Odb c.OdbcParameter ("DATE_TIME" ,
System.Data.Odb c.OdbcType.VarC har, 255, "DATE_TIME" ))
Me.OdbcInsertCo mmand1.Paramete rs.Add(New
System.Data.Odb c.OdbcParameter ("PAYLOAD",
System.Data.Odb c.OdbcType.VarC har, 255, "PAYLOAD"))
Me.OdbcInsertCo mmand1.Paramete rs.Add(New
System.Data.Odb c.OdbcParameter ("GTIN_DOMAI N",
System.Data.Odb c.OdbcType.VarC har, 255, "GTIN_DOMAI N"))
Me.OdbcInsertCo mmand1.Paramete rs.Add(New
System.Data.Odb c.OdbcParameter ("GTIN_CLASS ",
System.Data.Odb c.OdbcType.VarC har, 255, "GTIN_CLASS "))
'
'OdbcDeleteComm and1
'
Me.OdbcDeleteCo mmand1.CommandT ext = "DELETE FROM epctagWHERE
(ID = ?)"
Me.OdbcDeleteCo mmand1.Connecti on = Me.OdbcConnecti on1
Me.OdbcDeleteCo mmand1.Paramete rs.Add(New
System.Data.Odb c.OdbcParameter ("ID",System.Da ta.Odbc.OdbcTyp e.BigInt,
0, System.Data.Par ameterDirection .Input, False, CType(0, Byte),CType(0,
Byte), "ID", System.Data.Dat aRowVersion.Ori ginal, Nothing))
'
'OdbcUpdateComm and1
'
Me.OdbcUpdateCo mmand1.CommandT ext = "UPDATE ecptag SETID = ?,
OBJECT_EPC = ?, READER_EPC = ?, DATE_TIME = ?, PAYLOAD " & _
"= ?, GTIN_DOMAIN = ?, GTIN_CLASS = ? WHERE (ID = ?)"
Me.OdbcUpdateCo mmand1.Connecti on = Me.OdbcConnecti on1
Me.OdbcUpdateCo mmand1.Paramete rs.Add(New
System.Data.Odb c.OdbcParameter ("ID",System.Da ta.Odbc.OdbcTyp e.BigInt,
0, "ID"))
Me.OdbcUpdateCo mmand1.Paramete rs.Add(New
System.Data.Odb c.OdbcParameter ("OBJECT_EPC ",
System.Data.Odb c.OdbcType.VarC har, 255, "OBJECT_EPC "))
Me.OdbcUpdateCo mmand1.Paramete rs.Add(New
System.Data.Odb c.OdbcParameter ("READER_EPC ",
System.Data.Odb c.OdbcType.VarC har, 255, "READER_EPC "))
Me.OdbcUpdateCo mmand1.Paramete rs.Add(New
System.Data.Odb c.OdbcParameter ("DATE_TIME" ,
System.Data.Odb c.OdbcType.VarC har, 255, "DATE_TIME" ))
Me.OdbcUpdateCo mmand1.Paramete rs.Add(New
System.Data.Odb c.OdbcParameter ("PAYLOAD",
System.Data.Odb c.OdbcType.VarC har, 255, "PAYLOAD"))
Me.OdbcUpdateCo mmand1.Paramete rs.Add(New
System.Data.Odb c.OdbcParameter ("GTIN_DOMAI N",
System.Data.Odb c.OdbcType.VarC har, 255, "GTIN_DOMAI N"))
Me.OdbcUpdateCo mmand1.Paramete rs.Add(New
System.Data.Odb c.OdbcParameter ("GTIN_CLASS ",
System.Data.Odb c.OdbcType.VarC har, 255, "GTIN_CLASS "))
'
'Form1
'
Me.AutoScaleBas eSize = New System.Drawing. Size(5, 13)
Me.ClientSize = New System.Drawing. Size(608, 398)
Me.Controls.Add (Me.btnLoad)
Me.Controls.Add (Me.btnUpdate)
Me.Controls.Add (Me.DataGrid1)
Me.Name = "Form1"
Me.Text = "Form1"
CType(Me.DsTags 1,
System.Componen tModel.ISupport Initialize).End Init()
CType(Me.DataGr id1,
System.Componen tModel.ISupport Initialize).End Init()
Me.ResumeLayout (False)

End Sub

#End Region

Private Sub btnUpdate_Click (ByVal sender As System.Object,B yVal e
As System.EventArg s) Handles btnUpdate.Click
OdbcDataAdapter 1.Update(DsTags 1)
MessageBox.Show ("Database Updated!")
End Sub

Private Sub btnLoad_Click(B yVal sender As System.Object,B yVal e As
System.EventArg s) Handles btnLoad.Click
OdbcDataAdapter 1.Fill(DsTags1)
MessageBox.Show ("Data Table Loaded Successfully!")
End Sub
End Class
That's the long and short of it! Appreciate any help.


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

User submitted from AEWNET (http://www.aewnet.com/)
Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1772
by: Bj?rn Terje Svennes | last post by:
Using SQLBindParameter, I bind buffers to a prepared statement. Next time this statement is used I just replace the values in the buffer (not calling SQLBindParameter). This works fine when used within the same method. But the use of this statement can happen from several places in my code. When calling the statement a second time, the SQLExecute fails with return code SQL_NEED_DATA. The buffers are still valid and I haven't called...
7
3546
by: Együd Csaba | last post by:
Hi, I've a problem with some of my stored procs. My config is: RH7.1, Postgres 7.3.2 I had converted a few fields of a few tables from one type to another and after this I made all the necessary changes on the functions and recreated all my types and functions. It seemd to be all right, but the newly created functions won't work anymore.
3
3171
by: Nile | last post by:
I am having a problem with my application that uses ODBC. I am doing the following: * prepare a statement * Bind * execute The problem is that my application needs to accept only insert queries with parameter markers since it later writes to the database depending on the values in the SQL query.
6
4770
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much appreciated. Thanks in advance
0
1158
by: microsoft.public.dotnet.languages.csharp | last post by:
I am getting an error: ERROR Too few parameters. Expected 1 with the following code: public static string GetTitle(int CatID) { OdbcConnection conn = new OdbcConnection(ConfigurationSettings.AppSettings); OdbcCommand command = new OdbcCommand("SELECT Category FROM Categories WHERE CategoryID = @CID", conn); conn.Open(); command.Parameters.Add(new OdbcParameter("@CID", OdbcType.Int));
2
269
by: ME | last post by:
I am getting: "ERROR SQLBindParameter not used for all parameters" when attempting to run the following code: Private Sub DataGrid1_UpdateCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.UpdateCommand
3
2444
by: Adriano | last post by:
Hello, when I try to print something, either DataGrid or from Crystal Report viever the folowing error message appears and cancels printing: Object reference not set to an instance of an object :(((( Anyone pls help me to solve this problem!!! thanks in advance,
6
2465
by: Mikey G | last post by:
Hi, Here is a shorter code example since the last message I posted got truncated. So the problem is I created a simple VB.NET 2003 application through Visual Studio that connects to a MySQL database and loads a table into a Dataset, and then displays that table information in a DataGrid on a form for editing. The table fill works fine, the delete function works fine, but when I try to update a row, the application fails with the...
0
3032
by: Amarkumar Gopa | last post by:
Hi, I am getting the Db2 error -804. Some times, I am getting reason code 06 and some times 07. There is no change in the application program. Do you help me in identifying this error. DSNT408I SQLCODE = -804, ERROR: AN ERROR WAS FOUND IN THE APPLICATION PROGRAM INPUT PARAMETERS FOR THE SQL STATEMENT, REASON 07 DSNT418I SQLSTATE = 07002 SQLSTATE RETURN CODE DSNT415I SQLERRP = DSNXECP SQL...
0
9738
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11005
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10665
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10349
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9501
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7894
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5921
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4139
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3177
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.