0

Hey Guys,


I Want to Display Content of Database Into TextBox,
i.e.

i have column named "Ename" in "EMP" table of database1 ,

now i want to display "Ename" in TextBox of my form ,

so, how can i do this ?


Thanks In Advance

4
Contributors
11
Replies
12
Views
6 Years
Discussion Span
Last Post by Pgmer
0

i haven't written any code yet..
i just want to know how can i retrieve my table data into textbox

0

yes
i want to display one one item
i have employee details form,
each textbox should be filled from database

and i also want to use BINDING NAVIGATOR

0

write the Stored procedure in ur DB for selecting the records from DB and get those details in dataset, loop through dataset and assign to textbox accordingly.

0
For i As Integer = 0 To DataGridView1.Rows.Count - 1
                TextBox1.Text = DataGridView1.Rows.Item("Pass index or Columnname").ToString
            Next
0

look, i wrote this code
but i cant get the result

Try

            cn.Open()
            Dim da1 As New SqlDataAdapter
            Dim ds As New DataSet

            da1 = New SqlDataAdapter("select * from  Employee_Master", cn)
            da1.Fill(ds)
            DataGridView1.DataSource = ds.Tables(0)

            TextBox2_name.Text = DataGridView1.Rows.Item("2").ToString

        Catch ex As Exception
            MessageBox.Show(ex.ToString())

        Finally
            cn.Close()
        End Try
0

If you are using the second field in the row to fill the textbox then you can:

TextBox2_name.Text = DataGridView1.Rows.Item(2).ToString

Hope this helps

0

nop its isn't working

its giving output as " DataGridViewRow { Index=2 } "

can you please give me the complete code for this thing ?

0
Try

            Dim cn As SqlConnection
            Dim strCnn As String = "Your data base connection string"
            cn = New SqlConnection(strCnn)
            cn.Open()
            Dim comm As New SqlCommand("select * from  Employee_Master", cn)
            comm.CommandType = CommandType.Text

            Dim ds As SqlDataReader
            ds = comm.ExecuteScalar
            If ds.HasRows Then
                While ds.Read
                    ''
                    ' do what u want here using the data
                    TextBox2_name.Text = ds.Item(2)
                End While
            End If

            cn.Close()

        Catch ex As Exception
            MessageBox.Show(ex.ToString())

        Finally

        End Try
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.