0

Dear Experts

I use following codes to display data.
Next & Back buttons work fine, but when I enter some sno into textbox1 then it displays nothing

Codes on textbox1 lostfocus

Me.ds.Tables("employees").Rows.Find(Me.TextBox1.Text)

Codes in Form Load

Dim sql = "select * from employees"
        Dim da As New SqlClient.SqlDataAdapter(sql, con)
        ds.Clear()
        da.Fill(ds, "employees")
        TextBox1.DataBindings.Add("text", ds.Tables("employees"), "sno")
        TextBox2.DataBindings.Add("text", ds.Tables("employees"), "Name")
        TextBox3.DataBindings.Add("text", ds.Tables("employees"), "City")
        TextBox4.DataBindings.Add("text", ds.Tables("employees"), "Phone")

        Dim colpk(0) As DataColumn
        colpk(0) = ds.Tables(0).Columns("sno")
        ds.Tables(0).PrimaryKey = colpk

Codes on Next Button

Me.BindingContext(ds.Tables("employees")).Position += 1

Codes on Back Button

Me.BindingContext(ds.Tables("employees")).Position -= 1

How to display relevant data against column sno given in textbox1

Please help

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by tqmd1
0

Find() method of DataView return the row index.

ds.Tables("employees").DefaultView.Sort = "sno"
 Me.BindingContext(ds.Tables("employees")).Position = ds.Tables("employees").DefaultView.Find(TextBox1.Text)
0

Find() method of DataView return the row index.

ds.Tables("employees").DefaultView.Sort = "sno"
 Me.BindingContext(ds.Tables("employees")).Position = ds.Tables("employees").DefaultView.Find(TextBox1.Text)

Dear Sir,

When I use above code then it displays error message seen in JPG

Attachments dataset.JPG 109.65 KB
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.