Click here to Skip to main content
12,349,785 members (25,768 online)
Rate this:
 
Please Sign up or sign in to vote.
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:32pm
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

fill your retrieved value from database in dataset and assign like
TextBox1.Text=ds.Tables(0).Rows(0).Item("columnname").value
  Permalink  
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
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

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  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

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  
v2

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160621.1 | Last Updated 3 Nov 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100