Getting value from SQL query to textbox

Total Post:134


 1860  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
    ' 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?

  1. 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()


Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.