i really don't know how to slove the erro in my program..
..can you please help me?? thank you in advance
,..
Public Class Form1
Dim con As New OleDb.OleDbConnection
Dim cmd As New OleDb.OleDbCommand
Dim da As New OleDb.OleDbDataAdapter
Dim ds As New DataSet
Dim sql As String
Dim pos As Integer = 0
Dim recordcount As Integer = 0
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
con.ConnectionString = "PROVIDER = microsoft.ace.oledb.12.0;data source=dbcontacts.accdb"
con.Open()
sql = "SELECT * from tblcontacts"
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "CONTACTS_DS")
con.Close()
recordcount = ds.Tables("CONTACTS_DS").Rows.Count
bindcontrols()
End Sub
Private Sub bindcontrols()
ds = New DataSet("CONTACTS_DS")
da.Fill(ds, "CONTACTS_DS")
txtid.Text = ds.Tables("CONTACTS_DS").Rows(pos).Item("contactid")
txtname.Text = ds.Tables("CONTACTS_DS").Rows(pos).Item("Name")
txtmobileno.Text = ds.Tables("CONTACTS_DS").Rows(pos).Item("Mobileno")
End Sub
Private Sub cleartext()
txtid.Clear()
txtname.Clear()
txtmobileno.Clear()
End Sub
Private Sub cmdnext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdnext.Click
If pos < recordcount - 1 Then
pos = pos + 1
bindcontrols()
End If
End Sub
Private Sub cmdprevious_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdprevious.Click
If pos > 0 Then
pos = pos - 1
bindcontrols()
End If
End Sub
Private Sub cmdlast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdlast.Click
pos = recordcount - 1
bindcontrols()
End Sub
Private Sub cmdfirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdfirst.Click
pos = 0
bindcontrols()
End Sub
Private Sub cmdadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdadd.Click
cleartext()
txtid.Focus()
End Sub
Private Sub cmdsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdsave.Click
con.Open()
sql = "INSERT INTO tblcontacts VALUES(' " & txtid.Text & "','" & txtname.Text & "','" & txtmobileno.Text & "')"
cmd = New OleDb.OleDbCommand(sql, con)
cmd.ExecuteNonQuery()
con.Close()
ds = New DataSet("CONTACT_DS")
da.Fill(ds, "CONTACT_DS")
recordcount = recordcount + 1
bindcontrols()
End Sub
Private Sub cmdedit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdedit.Click
txtid.Focus()
End Sub
Private Sub cmdupdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdupdate.Click
con.Open()
sql = "UPDATE tblcontacts SET Name='" & txtname.Text & "', MobileNo='" & txtmobileno.Text & "'WHERE contactID='" & txtid.Text & "'"
cmd = New OleDb.OleDbCommand(sql, con)
cmd.ExecuteNonQuery()
con.Close()
ds = New DataSet("CONTACT_DS")
da.Fill(ds, "CONTATCS_DS")
bindcontrols()
End Sub
Private Sub cmddelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmddelete.Click
con.Open()
da.DeleteCommand = con.CreateCommand
sql = "DELETE FROM tblcontacts WHERE contactid = '" & txtid.Text & "'"
cmd = New OleDb.OleDbCommand(sql, con)
cmd.ExecuteNonQuery()
con.Close()
ds = New DataSet("CONTACT_DS")
recordcount = recordcount - 1
pos = pos - 1
bindcontrols()
End Sub
Private Sub cmdsearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdsearch.Click
sql = "SELECT * FROM tblcontacts WHERE contactid='" & txtsearch.Text & "'"
da = New OleDb.OleDbDataAdapter(sql, con)
ds = New DataSet("CONTACT_DS")
da.Fill(ds, "CONTACT_DS")
pos = 0
bindcontrols()
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
sql = "SELECT * FROM tblcontacts"
da = New OleDb.OleDbDataAdapter(sql, con)
ds = New DataSet("CONTACT_DS")
da.Fill(ds, "CONTACT_DS")
pos = 0
bindcontrols()
End Sub
Private Sub txtname_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtname.TextChanged
End Sub
End Class