SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Development Tools
 ASP.NET
 displaying data
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

sqldennis
Starting Member

2 Posts

Posted - 06/06/2010 :  19:32:20  Show Profile  Reply with Quote
the case:
im trying to display data from an acces database. the problem however is that, instead of showing all productID's, it shows only 1 productID and its price.
im new to sql and asp.net so im having a hard time getting this done.
im doing this in C#.
i should note that, after i figure this out, the productID's need to be clickable so it will redirect u to that productID's personal page.
in short, a webshop kind of idea.
my code in the aspx.cs currently looks like this, hope u guys can help.


protected void Page_Load(object sender, EventArgs e)
{



OleDbConnection verbinding = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source = C:/LOCATION/mydatabase.mdb");


try
{
verbinding.Open();

if (verbinding.State.ToString() == "Open")
{

string sqlstr = "SELECT ProductID, price FROM Product WHERE Producttype='Jeans'";


OleDbCommand cmd = new OleDbCommand(sqlstr, verbinding);
OleDbDataReader lees = cmd.ExecuteReader();
lees.Read();
Label1.Text = lees["ProductID"].ToString();
Label2.Text = lees["price"].ToString();
lees.Close();


}
}
catch (Exception x)
{
Label1.Text = "Database Error: " + x.Message;
Label2.Text = "Database Error: " + x.Message;
}
finally
{
verbinding.Close();
}

}

Edited by - sqldennis on 06/06/2010 19:33:49

expat
Starting Member

Thailand
7 Posts

Posted - 06/16/2010 :  00:51:23  Show Profile  Reply with Quote
Try this.

while (lees.Read())
{
Label1.Text = lees["ProductID"].ToString();
Label2.Text = lees["price"].ToString();
}
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.09 seconds. Powered By: Snitz Forums 2000