954,517 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to show Table data in Texbox

Hi i am new user of Dot net and i want to show table data into a textbox from data reader but i dont know how to asing value to textbox.
plzzzzzzzzzzzz help me

Ifiii
Newbie Poster
1 post since Mar 2009
Reputation Points: 10
Solved Threads: 0
 

Private Sub btnExecuteReader_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnExecuteReader.Click

' Create an instance of an Connection object
Dim cnn As OleDbConnection = New OleDbConnection( _
"provider=SQLOLEDB;server=localhost;uid=sa;database=pubs")
' Create instance of Command object
Dim cmd As OleDbCommand = New OleDbCommand()
txtResults.Clear()
' Set command's connection and command text
cmd.Connection = cnn
cmd.CommandType = CommandType.Text
cmd.CommandText = "select * from tablename where param1=@param1"
' Create parameter and set value
cmd.Parameters.Add(New SqlParameter("@param1", SqlDbType.Int))
cmd.Parameters("@param1").Direction = ParameterDirection.Input
cmd.Parameters("@param1").Value = Val(txtParam1.Text)

' Must open the Connection before calling ExecuteReader()
cnn.Open()
Dim reader As OleDbDataReader
reader = cmd.ExecuteReader()
While reader.Read()
txtResults.Text = txtResults.Text & reader("fname") & _
ControlChars.Tab & reader("lname") & _
ControlChars.Tab & ControlChars.Tab & _
reader("job_desc") & ControlChars.CrLf
End While
reader.Close()
cnn.Close()
End Sub

This should give you the solution to the problem

atplerry
Junior Poster in Training
58 posts since Jul 2007
Reputation Points: 10
Solved Threads: 3
 

how to to show data from a table using list box in vb.net

choc0
Newbie Poster
1 post since Sep 2010
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You