Dear Developers
I have following codes on lostfocus of textbox1.text to search values.
It works fine but how to navigate database. I mean what codes should I use for Next Record and Previous Record Buttons.
My SQL database name is accounts and table name is employees
Please help
str = "select * from employees where sno =" & Val(Me.TextBox1.Text)
dt = GetTable(str)
If (dt.Rows.Count >= 1) Then
Me.TextBox2.Text = dt.Rows(0)("name")
Me.TextBox3.Text = dt.Rows(0)("city")
Me.TextBox4.Text = dt.Rows(0)("phone")
Else
Me.TextBox2.Text = ""
Me.TextBox3.Text = ""
Me.TextBox4.Text = ""
End If
'this function is in main module
Public Function GetTable(ByVal mstr As String)
cmd = New SqlClient.SqlCommand(mstr, con)
da = New SqlClient.SqlDataAdapter(cmd)
dt = New DataTable
da.Fill(dt)
Return (dt)
End Function
I have following codes on lostfocus of textbox1.text to search values.
It works fine but how to navigate database. I mean what codes should I use for Next Record and Previous Record Buttons.
My SQL database name is accounts and table name is employees
Please help
str = "select * from employees where sno =" & Val(Me.TextBox1.Text)
dt = GetTable(str)
If (dt.Rows.Count >= 1) Then
Me.TextBox2.Text = dt.Rows(0)("name")
Me.TextBox3.Text = dt.Rows(0)("city")
Me.TextBox4.Text = dt.Rows(0)("phone")
Else
Me.TextBox2.Text = ""
Me.TextBox3.Text = ""
Me.TextBox4.Text = ""
End If
'this function is in main module
Public Function GetTable(ByVal mstr As String)
cmd = New SqlClient.SqlCommand(mstr, con)
da = New SqlClient.SqlDataAdapter(cmd)
dt = New DataTable
da.Fill(dt)
Return (dt)
End Function