Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Mar 26, 2012 04:56 AM by Mikesdotnetting
Mar 24, 2012 10:48 PM|LINK
Hi, im looking for a simple code where i can for example have 1 record from my access database as a label.
I am creating a shopping website so my database consists of product names. i want one of these products names to come up as a label in my asp.net page.
Can anyone help?
Thanks so much
Mar 25, 2012 06:44 AM|LINK
You can use Database.QuerySingle to read one record, or Database.QueryValue to read one value such as a product name:
var db= Database.Open("MyConnectionStringName")
var product = db.QueryValue("Select ProductName From Products WHERE ProductId = @0, Request["productId"]);
Read this tutorial for more information on working with data in Web Pages: http://www.asp.net/web-pages/tutorials/data/5-working-with-data
Mar 25, 2012 09:42 PM|LINK
Hi, im using asp.net webmatrix and still new to this, i didnt manage to get any information (that i really understood) from that link haha. Will i stil be able to use that code you gave me in webmatrix? thanks anyway for your help
Mar 26, 2012 03:16 AM|LINK
You can create a cshtml file then use the code the Mike provide to you.
I think it should work.
change the SQL querystring to your own.
Mar 26, 2012 04:56 AM|LINK
That code is for WebMatrix (ASP.NET Web Pages). I think you had better start at the first tutorial and work your way through them otherwise nothing else is likely to make sense to you.