943,752 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 1271
  • VB.NET RSS
Mar 25th, 2009
0

How to show Table data in Texbox

Expand Post »
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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Ifiii is offline Offline
1 posts
since Mar 2009
Mar 25th, 2009
0

Re: How to show Table data in Texbox

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
Reputation Points: 10
Solved Threads: 3
Junior Poster in Training
atplerry is offline Offline
58 posts
since Jul 2007
Sep 20th, 2010
0
Re: How to show Table data in Texbox
how to to show data from a table using list box in vb.net
Reputation Points: 10
Solved Threads: 0
Newbie Poster
choc0 is offline Offline
1 posts
since Sep 2010

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: help me..with my voting system in access 2003
Next Thread in VB.NET Forum Timeline: menu drop down





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC