anyone can help? i want to check whether the data has been exist or not. but its shows some error in this code.
error :No value given for one or more required parameters.
Public Sub doSave()
Dim con As New OleDb.OleDbConnection(My.Settings.KK3DB)
Dim cmd As New OleDb.OleDbCommand
Dim adap As New OleDb.OleDbDataAdapter
Dim ds As New DataSet
Dim dr As OleDb.OleDbDataReader
con = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\backup project\KK3MailingSystem\KK3MailingSystem\KK3MailingSystem\db\KK3MailingSystem.mdb;Persist Security Info=True")
con.Open()
cmd.CommandText = "SELECT * FROM Staff WHERE Staff_Id =" & txtId.Text & ""
cmd = New OleDbCommand(cmd.CommandText, con)
dr = cmd.ExecuteReader()
If Not dr.HasRows Then
cmd.CommandText = " INSERT INTO Staff (Staff_Id,Staff_Name, Staff_IC,Staff_Ext,Staff_HP,Staff_Email,Staff_Position,Staff_Username) VALUES ('" + txtId.Text + "','" + txtName.Text + "','" + txtIC.Text + "','" + txtExt.Text + "','" + txtHP.Text + "','" + txtEmail.Text + "','" + cboPosition.Text + "','" + txtId.Text + "')"
cmd = New OleDbCommand(cmd.CommandText, con)
Dim icount As Integer = cmd.ExecuteNonQuery
MessageBox.Show(icount)
Else
MsgBox(" Record exists")
End If
End Sub