Click here to Skip to main content
12,953,230 members (64,968 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
Please Sign up or sign in to vote.

Solution 1

fill your retrieved value from database in dataset and assign like
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


TextBox1.Text = dt.Rows(0).Item("max").ToString
Rate this: bad
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 :)

Best Regards,
Sunny K
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

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"));

pls check that one

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
OriginalGriff 6,429
CHill60 3,490
Maciej Los 3,103
Jochen Arndt 1,975
ppolymorphe 1,920

Advertise | Privacy | Mobile
Web01 | 2.8.170525.1 | Last Updated 3 Nov 2012
Copyright © CodeProject, 1999-2017
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