problem in binding and move between records after search

flodi

Member
Joined
Jan 23, 2008
Messages
15
Location
Makkah Al Mukarramah, Makkah, Saudi Arabia, Saudi
Programming Experience
Beginner
hi all
this my 1st post
am faceing problem in moving between records that i search
when i do the search it done correct but if i had a multiable records in that search i want to go throw it also but in my cod it does not it only show me 1 records and when i press the next button it goes the next one in the table no the next search
and i post here my code hope make you all understanding me better
VB.NET:
Dim ds As New DataSet
    Dim da As New SqlDataAdapter
    Dim bind As New BindingSource
    Private Sub users_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        SqlConnection1.Open()
        da = New SqlDataAdapter("select * from em_user", SqlConnection1)
        da.FillSchema(ds, SchemaType.Source, "em_user")
        da.Fill(ds, "em_user")
        bind.DataSource = ds
        bind.DataMember = "em_user"
        Me.TextBox1.DataBindings.Add("Text", bind, "em_name")
        Me.TextBox2.DataBindings.Add("Text", bind, "id_no")
        Me.ComboBox1.DataBindings.Add("Text", bind, "em_level")
        Me.ComboBox2.DataBindings.Add("Text", bind, "em_sec")
        Me.UserText.DataBindings.Add("Text", bind, "em_user_name")
        Me.PassText.DataBindings.Add("Text", bind, "em_password")
        Me.Pass1Text.DataBindings.Add("Text", bind, "em_rpassword")
        Me.ComboBox3.DataBindings.Add("Text", bind, "user_type")
        SqlConnection1.Close()
        Label14.Text = username
in this code there is no problem it show me all records and i can go throw all it by code ( bind.movenext ) and ( bind.moveperviouse )
and here is my search code
VB.NET:
If RadioButton1.Checked = True Then
            If TextBox1.Text = "" Then
                MsgBox("wrong search,please enter name")
                Call cancel()
                Call clear()
            Else
                SqlCommand4.Parameters("@em_name").Value = TextBox1.Text
                Dim read As SqlClient.SqlDataReader
                SqlConnection1.Open()
                read = SqlCommand4.ExecuteReader
                If Not read.Read Then
                    MsgBox("em name not found")
                    read.Close()
                    SqlConnection1.Close()
                    Call cancel()
                    Call clear()
                Else
                    TextBox1.Text = read.Item("em_name")
                    ComboBox1.Text = read.Item("em_level")
                    ComboBox2.Text = read.Item("em_sec")
                    UserText.Text = read.Item("em_user_name")
                    PassText.Text = read.Item("em_password")
                    Pass1Text.Text = read.Item("em_rpassword")
                    TextBox2.Text = read.Item("id_no")
                    ComboBox3.Text = read.Item("user_type")
                                        ds.Tables("em_user").DefaultView.RowFilter = "em_name" Like "@em_name + N '%'"
read.Close()
                    SqlConnection1.Close()
                End If
            End If
        End If
i hope you all understand my problem and find my mistake and show it to me
thanks

sorry i forget to tell you that am using vb.net2005 with sql server2000 database
 
Please read the DW2 link in my signature, section "Creating a SImple Data App" then read related articles. In .NET 2 you should never really be adding the databindings yourself.. it seems like youre following a very old tutorial or an old programming style. Its' time to update
 
Back
Top