-
display problem
i was trying to display the data into an label but i fail, the label only display "FALSE", i dun know why. can somebody told me what wrong with my code? thanks
this is my code:
Dim myConnection As SqlConnection = New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\DayMenu.mdf;Integrated Security=True;User Instance=True")
Dim myCommand As SqlCommand = New SqlCommand("select resname, tmenu, price, date FROM menu where resname = 'sakura'", myConnection)
myConnection.Open()
Dim dr As SqlDataReader = myCommand.ExecuteReader()
If reslist.SelectedValue = ListItem.FromString("sakura").ToString Then
menulabel.Text = dr.Read
End If
myConnection.Close()
-
If you look at the documentation of the DataReader's Read method (http://msdn2.microsoft.com/en-us/lib...ader.read.aspx ; also available by highlighting the word "Read" in your code and pressing F1), you'll see that it returns a Boolean. That's why you're getting the word "False" in your label.
For information on how to use a SqlDataReader, please see this tutorial: http://samples.gotdotnet.com/quickst...ldtreader.aspx
Phil Weber
http://www.philweber.com
Please post questions to the forums, where others may benefit.
I do not offer free assistance by e-mail. Thank you!
Similar Threads
-
By matthewst in forum VB Classic
Replies: 6
Last Post: 11-14-2006, 07:31 AM
-
By matthewst in forum XML
Replies: 1
Last Post: 11-09-2006, 07:41 AM
-
By dbrook007 in forum ASP.NET
Replies: 0
Last Post: 11-06-2006, 04:54 AM
-
By Steve Ash in forum VB Classic
Replies: 5
Last Post: 04-24-2001, 06:51 PM
-
By Tony cyriac in forum Java
Replies: 1
Last Post: 05-29-2000, 11:26 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks