Home > DeveloperSection > Forums > Getting value from SQL query to textbox
Tanuj Kumar

Total Post:134

Posted on    August-28-2014 1:25 AM


 1 Reply(s)
 1184  View(s)
Rate this:

Protected Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click

    Dim cons, query As String

    Dim con As OdbcConnection

    Dim adpt As OdbcDataAdapter

    'Dim num As Integer

    cons = "dsn=Courier; UID=Courier; PWD=123;"

    con = New OdbcConnection(cons)


    query = "select Name from EMPLOYEE where EMPLOYEE_ID=" + DropDownList1.SelectedValue

    Dim ds As DataSet

    adpt = New OdbcDataAdapter(query, con)

    ds = New DataSet

    adpt.Fill(ds, "Courier")

    ' TextBox1.Text = ds


End Sub

I want to display the name of the employee in Textbox whoos ID is specified in query, what can I do for that?

Sumit Kesarwani

Total Post:378

Posted on    August-28-2014 2:15 AM

Hi Tanuj, 

You should use DataRow but to answer your question, try this.

TextBox1.Text = ds.Tables(0).Rows(0)("Name").ToString()

Don't want to miss updates? Please click the below button!

Follow MindStick