Click here to Skip to main content
15,895,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Coders,

I would like to have some help regarding fetch the data from sql server to visual studio in a textbox. I actually had worked on this by deriving data from a datagridview and then to a text box. But now i really need a straightway to get the data directly to the textbox. Please Help.
Posted

fill your retrieved value from database in dataset and assign like
TextBox1.Text=ds.Tables(0).Rows(0).Item("columnname").value
 
Share this answer
 
v2
Comments
armarzook 4-Nov-12 9:34am    
Used the below code to get what i want but its still not working...

Private Sub ComboBox1_SelectedIndexChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged


TextBox2.Text = ComboBox1.SelectedValue

con.ConnectionString = myconstring

Dim da As New SqlDataAdapter("SELECT max(sl_no) as max FROM e1 where project_id='" + TextBox1.Text + "'", con)

Dim dt As New DataTable

da.Fill(dt)

MsgBox("Connected")
MsgBox(dt.Rows(0).Item("max").ToString)
TextBox1.Text = dt.Rows(0).Item("max").ToString
Hi armarzook,

I would suggest you to use a BindingSource control to achieve this purpose.

For details, you can refer to the link below:
Quickest Way to Create a .NET Database Application[^]



Hope this helps!
Happy Coding :)

Best Regards,
Sunny K
 
Share this answer
 
Hi may be your problem is grid textbox assigning your datebase value thats right

protected void gridview1_RowDataBound(object sender, GridViewRowEventArgs e)
   {
       if (e.Row.RowType == DataControlRowType.DataRow)
       {
        Textbox TextBox1= ((Textbox)e.Row.FindControl("textboxID"));
          TextBox1.Text=ds.Tables(0).Rows(0).Item("columnname").value
                    
         }
       }

pls check that one
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900