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.

Edited 6 Years Ago by __avd: Added [code] tags. For easy readability, always wrap programming code within posts in [code] (code blocks).

DBNull.Value. This assignment is valid for a column of any type.

IF IsNumeric(TxtLani.Text)=false Then
     cmd.Parameters.AddWithValue("@Lani_Lani Rs", DBNull.Value)
 ELSE
     cmd.Parameters.AddWithValue("@Lani_Lani Rs", txtlani.Text)
 END IF

Sir,
While I am running the project the cursor is blinking in the first name textbox then i am press the tab button then it is move to middle name textbox and then lastname and company name but when I am press after company name then it will jump to the button I want to jump the tab into Lani in Rs which is the next to company name textbox and then it will jump to Enter date.

I am having problem in the Enter Date field in the back end in the MS access I have already set the date in the back end i.e. short Date so, how to Formate the textbox in the front end i.e. in vb.net 2005

Please help me.

This question has already been answered. Start a new discussion instead.