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?

Recommended Answers

All 2 Replies

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()
commented: to the point :) nice work +4

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! :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.