Hi all I am trying to insert a record into MS-Access database using VS2008 as front end and this is my code i am using to connect to the database.
login.mdb has two tables(login,schedules)
Dim con As New OleDb.OleDbConnection
Dim cmd As OleDbCommand
Dim myquery As String
Dim count As Integer
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\login.mdb"
con.Open()
Try
myquery = "INSERT INTO schedules VALUES('" & (txtcompanyname.Text) & _
"','" & (rtaddress.Text) & _
"','" & (txtcontactperson.Text) & _
"','" & CInt(txtphoneno.Text) & _
"','" & (txtemailid.Text) & _
"','" & (rtabout.Text) & _
"','" & (txtwebsite.Text) & _
"','" & (comboindustry.SelectedItem) & _
"','" & (combojobcategory.SelectedItem) & _
"','" & (txtvacancy.Text) & _
"','" & (combosalaryrange.SelectedItem) & _
"','" & (combotype.SelectedItem) & _
"','" & (DateTimePicker1.Value) & _
"','" & (combotime.SelectedValue) & _
"','" & (txtvenue.Text) & _
"','" & (rtotherinfo.Text) & "')"
cmd = New OleDbCommand(myquery, con)
count = cmd.ExecuteNonQuery()
MsgBox(" Number of Records inserted : " & count)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, Me.Text)
End Try
con.Close()
Msgbox displays (Number of Records inserted:1) but nothing gets inserted!
I want to use company name+date field as a primary key for inserting or updating a record little help needed here.