Click here to Skip to main content
Sign Up to vote bad
good
See more: SQL-ServerVB.NET, +
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 2 Nov '12 - 20:32


3 solutions

fill your retrieved value from database in dataset and assign like
TextBox1.Text=ds.Tables(0).Rows(0).Item("columnname").value
  Permalink  
Comments
armarzook - 4 Nov '12 - 9:34
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 Smile | :)
 
Best Regards,
Sunny K
  Permalink  
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
  Permalink  

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 415
1 OriginalGriff 315
2 Slacker007 240
3 Maciej Los 240
4 Aarti Meswania 210
0 Sergey Alexandrovich Kryukov 8,953
1 OriginalGriff 7,134
2 CPallini 3,758
3 Rohan Leuva 3,066
4 Maciej Los 2,528


Advertise | Privacy | Mobile
Web03 | 2.6.130516.1 | Last Updated 3 Nov 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid