i have an app which maintains an access DB and i have a problem with inserting data into it
i am using oledb.command and executing it as a nonquery command
when i use the sql string which is built in the app directly in access the insert doesn't make any problems
but when i try to run it in VB it always returns this error (attachment)
can anyone help?
thanks
object reference not set to an instance of an object... an error which got my jaw dropped for a while. it's just hte keyword new -- make sure you have all objects declared as new, like Dim objCmd as New OleDbCommand(strSQL, objConn) etc. without new would give you an error.
Private Sub BtnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Dim conAdd As OleDbConnection = New OleDbConnection(conExp.ConnectionString)
Dim comAdd As OleDbCommand
Dim comStr As String, den As String
Dim comInt As Integer
den = CStr(calAdd.SelectionStart)
conAdd.Open()
comStr = "insert into exp values(" + intID() + "," + intKat() + "," + CStr(txtSum.Text) + ",'" + CStr(den) + "','" + CStr(txtMemo.Text) + "')"
comAdd.CommandText = comStr
comInt = comAdd.ExecuteNonQuery()
End Sub