How to show Table data in Texbox

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Mar 2009
Posts: 1
Reputation: Ifiii is an unknown quantity at this point 
Solved Threads: 0
Ifiii Ifiii is offline Offline
Newbie Poster

How to show Table data in Texbox

 
0
  #1
Mar 25th, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 55
Reputation: atplerry is an unknown quantity at this point 
Solved Threads: 3
atplerry atplerry is offline Offline
Junior Poster in Training

Re: How to show Table data in Texbox

 
0
  #2
Mar 25th, 2009
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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC