Hey Guys,

I Want to Display Content of Database Into TextBox,

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

Recommended Answers

All 11 Replies

What is your code for this? Please post ur code and the problem with the code.

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

So you want to display one one item? If one, which one? If more, you better use Listobx control.

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

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.

ok i got it
now just tell me code for assigning value from dataset to textbox

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

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


            Dim da1 As New SqlDataAdapter
            Dim ds As New DataSet

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

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

        Catch ex As Exception

        End Try

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

nop its isn't working

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

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


            Dim cn As SqlConnection
            Dim strCnn As String = "Your data base connection string"
            cn = New SqlConnection(strCnn)
            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


        Catch ex As Exception


        End Try
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.