Show Result in textbox

Discussion in '.NET' started by morten-mb, Jun 17, 2008.

  1. morten-mb

    morten-mb

    Joined:
    Jun 16, 2008
    Messages:
    1
    Hi,

    I'm maybe a bit newbie to ASP.NET 2.0 but trying to learn.
    I have difficult to show result of a query in textbox, but it works fine in a GridView.


    For example, I have this code:




    Protected Sub B_Search_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles B_Search.Click
    Dim test

    test = txtsearch.Text

    Dim cs As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\customer.mdf;Integrated Security=True;User Instance=True"
    Using con As New System.Data.SqlClient.SqlConnection(cs)
    con.Open()
    Dim cmd As New System.Data.SqlClient.SqlCommand
    cmd.Connection = con
    cmd.CommandType = Data.CommandType.Text
    cmd.CommandText = "SELECT companyName FROM T_Customer WHERE companyID like '" + test + "'"
    Using reader As System.Data.SqlClient.SqlDataReader = cmd.ExecuteReader


    'This only returns System.Data.SqlClient.SqlDataReader in txtResult.Text :

    txtResult.Text = reader.ToString
    txtResult.DataBind()

    'But this is working:

    GridView1.DataSource = reader
    GridView1.DataBind()



    End Using

    End Using

    End Sub



    Any suggestion how to to get the result in txtResult.Text?
     
    morten-mb, Jun 17, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. J.Ram
    Replies:
    7
    Views:
    655
  2. Pavel
    Replies:
    7
    Views:
    539
    Pavel
    Sep 19, 2010
  3. Lakshmi Sreekanth

    i = 10; result = ++i - --i; How result become ZERO

    Lakshmi Sreekanth, Sep 21, 2010, in forum: C Programming
    Replies:
    52
    Views:
    1,190
    Nick Keighley
    Sep 23, 2010
  4. Mr. Buffoon
    Replies:
    4
    Views:
    325
    Eric Sosman
    Sep 23, 2010
  5. Michael Tan
    Replies:
    32
    Views:
    1,006
    Ara.T.Howard
    Jul 21, 2005
Loading...

Share This Page