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)
Dim dr As SqlDataReader = myCommand.ExecuteReader()
If reslist.SelectedValue = ListItem.FromString("sakura").ToString Then
menulabel.Text = dr.Read
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
Please post questions to the forums, where others may benefit.
I do not offer free assistance by e-mail. Thank you!
By matthewst in forum VB Classic
Last Post: 11-14-2006, 07:31 AM
By matthewst in forum XML
Last Post: 11-09-2006, 07:41 AM
By dbrook007 in forum ASP.NET
Last Post: 11-06-2006, 04:54 AM
By Steve Ash in forum VB Classic
Last Post: 04-24-2001, 06:51 PM
By Tony cyriac in forum Java
Last Post: 05-29-2000, 11:26 AM
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