0

How to retrieve the particular column row to the text box?
I mean how to display it in textbox?
The column has got different rows.
The code I wrote in vb net is :

cmd = New SqlCommand("select ida from Issue where aname='" + TextBox3.Text + "'", con)
In the above line I compare the textbox3 data in the table.
And if the data matches then it should display **the ida that matches with aname row ** to textbox4.

I am doing something wrong for sure as I wrote it int his way:
textbox4.text=cmd.ToString.

The above line din't give any error and it din't show anything in textbox4 also.

So ,how to display it?

3
Contributors
2
Replies
6
Views
5 Years
Discussion Span
Last Post by Philippe.Lahaie
1

use reader,

cmd = New SqlCommand("select ida from Issue where aname='" + TextBox3.Text + "'", con)
Dim reader As New SqlDataReader = cmd.ExecuteReader
If reader.Read()
   TextBox4.Text = reader("column name in database that you want to display").ToString
End If
reader.Close()
cmd.Dispose()
conn.Close()
Votes + Comments
to the point :) nice work
0

the SQL command itself is not what you want to print,

first the terms you are using are backwards, its hard to read you when you use "column" and mean row, and "row" when you mean column! ;)

now, you will want to create a SQLDataReader and set it to the cmd's ExecuteReader() method

here is a snippet for this

shoudl've searched a bit before posting! :)

Edited by Philippe.Lahaie: typo

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.