Mohammad Ishaq

Mohammad Ishaq

  • NA
  • 55
  • 19.1k

Help to correct the code for text box

May 31 2014 10:33 AM

I have two text box on vb form and i am using access table . i want to receive data from two column in to my two text box .

I have write the code and debug it successfully but there is no data show in the boxes.
Please guide me to solve my problem.Thanks

The code are


Public Class Form1
    Dim cn As System.Data.OleDb.OleDbConnection

    Private Sub EmplysrceDataBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


       
        cn = New System.Data.OleDb.OleDbConnection
        cn.ConnectionString = ("Provider=Microsoft.JET.OLEDB.4.0;" & "Data Source=E:\a.mdb;")
        cn.Open()

        Showitems()
    End Sub

    Private Sub Showitems()

        Dim ds As New DataSet
        Dim dt As New DataTable
        ds.Tables.Add(dt)
        Dim da As New OleDb.OleDbDataAdapter
        da = New OleDb.OleDbDataAdapter("Select *  From EmplysrceData", cn)

        da.Fill(dt)

        TextBox1.Text = dt.Rows(1).Item(0)
        TextBox2.Text = dt.Rows(1).Item(1)

        cn.Close()


    End Sub


End Class


Answers (2)