I must be missing something real easy here, but I can not seem to insert data into access using .net. Here is my code.
Thanks,
Dim MyConnection As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\AJS Contact Management.mdb")
MyConnection.Open()
Dim strCommand As String = "Select * from Companies where company = '" & Replace(cmbcompany.Text, "'", "''") & "'and Contact = '" & Replace(cmbcontact.Text, "'", "''") & "'"
Dim mycommand As New OleDbCommand(strCommand, myconnection)
Dim myreader As OleDbDataReader = mycommand.ExecuteReader
If Not myreader.HasRows Then
myreader.Close()
mycommand.Dispose()
strCommand = "INSERT INTO Companies (company, address, city, state, zip, contact, sal, phone, ext, fax, email, customertype, discount VALUES ('" & cmbcompany.Text & "', '" & txtaddress.Text & "', '" & txtcity.Text & "', '" & cmbstate.Text & "', '" & txtzip.Text & "', '" & cmbcontact.Text & "', '" & cmbsalutation.Text & "', '" & txtphone.Text & "', '" & txtext.Text & "', '" & txtfax.Text & "', '" & txtemail.Text & "', '" & cmbcusttype.Text & "', '" & txtdiscount.Text & "'"
mycommand = New OleDbCommand(strCommand, myconnection)
mycommand.ExecuteNonQuery()
Else
MessageBox.Show("NAME ALREADY EXISTS!")
End If
myconnection.Close()
myreader.Close()
mycommand.Dispose()