Dim Cname As String
Dim CID As Integer
Dim Rmaterial As String
con = New OleDbConnection("Provider=Microsoft.ace.Oledb.12.0;Data Source= C:\Users\Lenovo\Documents\Visual Studio 2010\Soft\Database\Login.accdb")
con.Open()
cmd = New OleDbCommand("select * from Purchase where CompanyID='" & txtnum.Text & "'", con)
dr = cmd.ExecuteReader()
If txtname.Text = "" And txtnum.Text = "" And txtraw.Text = "" Then
MessageBox.Show(" Enter All The Feilds", "Done", MessageBoxButtons.OK, MessageBoxIcon.Information)
ElseIf dr.Read() Then
MessageBox.Show("Company ID already exist", "Done", MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
CID = Convert.ToInt32(txtnum.Text)
Cname = txtname.Text
Rmaterial = txtraw.Text
cmd = New OleDbCommand("INSERT INTO Purchase VALUES( '" & Cname & "'," & CID & ",'" & Rmaterial & "')", con)
cmd.ExecuteNonQuery()
MessageBox.Show("Added successfully", "Done", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
cmd = New OleDbCommand("Select * from Purchase", con)
dr = cmd.ExecuteReader()
Dim dt As New DataTable("Purchase")
dt.Load(dr)
DataGridView1.DataSource = dt
End Sub
Why do i get the error "Data type mismatch in criteria expression"