Hi,
is there anybody who can help me?
I've a problem in defining parameter markers.
'I've opened an ODBC connection to Microsoft Access Driver
and the connstring is
Dim strConnectionString As String = "Driver={Microsoft
Access Driver (*.mdb)};DBQ=C:\Documents and
Settings\ug.AXISDM\Documenti\Biblioteca.mdb"
'The SQL Select statement is
Dim pInsertQuery As String = "SELECT ID,[AUTORE/I], TITOLO
FROM LIBRERIA"
'I added an OdbcDataAdapter,DataSet and a DataGrid
Dim adapter As New OdbcDataAdapter(pInsertQuery, pConn)
Dim titleDS As DataSet = New DataSet()
adapter.Fill(titleDS, "LIBRERIA")
DataGrid1.SetDataBinding(titleDS, "LIBRERIA")
DataGrid1.Show()
'In order to Update a record I've created the following
event
Private Sub btnAggiorna_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
btnAggiorna.Click
Dim objCommand As OdbcCommand = New
OdbcCommand()
objCommand.Connection = pConn
objCommand.CommandText = "UPDATE LIBRERIA SET
[AUTORE/I] = ?, TITOLO = ? WHERE ID = ?"
objCommand.CommandType = CommandType.Text
pConn.Open()
Try
objCommand.ExecuteNonQuery()
Catch err As OdbcException
MessageBox.Show(err.Message)
End Try
pConn.Close()
titleDS.Clear()
adapter.Fill(titleDS, "LIBRERIA")
DataGrid1.SetDataBinding(titleDS, "LIBRERIA")
DataGrid1.Show()
End Sub
***********************************************************
Now the point is: if I define a value for fields in the
Update statement such as "UPDATE LIBRERIA SET [AUTORE/I]
='tom', TITOLO = 'the beginners' WHERE ID = '1'"
of course it works and I obtain a new record in place of
the old ID=1.
But, if I use a question mark as value I get an error:
ERROR[07002][Microsoft][Driver ODBC Microsoft Access]COUNT
FIELD INCORRECT
I know that I must set parameters properties, but I really
don't know how to do.
It seems to work differently from an OLEDB Connection and
at the end I'm not in measure to update my DataGrid.
Hope somebody helps me!
Thanks Ugo