GETTING VALUE FROM SQL QUERY TO TEXTBOX

Tanuj Kumar

Total Post:134

Points:940
Posted by  Tanuj Kumar
VB.Net 
 1490  View(s)
Ratings:
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)
    con.Open()
    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
    con.Close()
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?

  1. Sumit Kesarwani

    Post:378

    Points:2694
    Re: Getting value from SQL query to textbox

    Hi Tanuj, 

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

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

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!