Sir,
I am using 6 textboxes and three button one for insert data second for update and third for delete the data while inserting and updating the record it generate an error i.e. "Data type mismatch in criteria expression" in the backend i.e in MS Access I am using this column
1. Sr No (PK)
2. First Name
3. Middle Name
4. Last Name
5. Company Name
6. Lani in Rs. (Currency)
7. Date (Short Date)
Further I want the user should leave blank while entering the data 6 (Lani in Rs) and 7 (Date) textbox. So I want in the back end how to set the value NULL in the field.
Here is my insert code in the vb.net i.e. front end.
Kindly help me for that.
the following procedure will call in button click event.
Private Sub Addmembers()
Try
'Dim ContactName As String = connametxtbox.Text
' Build Insert statement to insert new Contact into the Contact table
'Dim myDataSet As DataSet = New DataSet()
Dim cmd As OleDbCommand
Dim con As OleDbConnection
con = New OleDbConnection(connectionString)
cmd = New OleDbCommand(Add_members, con)
' this is the declaration part at the top
Dim Add_members As String = "Insert into [Lani]([First Name],[Middle Name],[Last Name],[Company Name],[Lani Rs],[Date]) values([First Name],[Middle Name],[Last Name],[Company Name],[Lani Rs],[Date]);"
cmd.Parameters.AddWithValue("@Lani_First Name", txtfirst.Text)
cmd.Parameters.AddWithValue("@Lani_Middle Name", txtmiddle.Text)
cmd.Parameters.AddWithValue("@Lani_Last Name", txtlast.Text)
cmd.Parameters.AddWithValue("@Lani_Company Name", txtcomp.Text)
cmd.Parameters.AddWithValue("@Lani_Lani Rs", txtlani.Text)
cmd.Parameters.AddWithValue("@Lani_Date", txtdate.Text)
'cmd.Parameters.AddWithValue("@Lani_Lani Rs", txtlani.Text)
'PopulateProductList()
'con = New OleDbConnection(connectionString)
con.Open()
'cmd = New OleDb.OleDbCommand(Str, con)
cmd.ExecuteNonQuery()
con.Close()
' Close and Clean up objects
'ShowData()
'PopulateProductList()
con.Dispose()
cmd.Dispose()
Catch ex As OleDbException
MsgBox(ex.Message.ToString)
'insertOk = False
End Try
End Sub
Please Help me.