Hello
I have a website which uses an Access databse.
The user makes a selection and the answer/s are shown.
I have some code which counts the amount of records and then either displays an error message or shows the products.
What I would like to do is work out if there is only 1 record and what the name of the 1 serial number is for that record.
EG, my database has 2 columns
ID and SerialNumber
Simply put, my ideal code would be
If there is only 1 record, then get the SerialNumber. Then, Redirect to www. My Serial Number .com
My code so far (Please note it is Line 12 which has the problem):
I know this won't work as it's not part of a databound control and so I can't use the Eval.
How do I just read this value from the databse and insert it into (line12)?
Thanks
Dave
I have a website which uses an Access databse.
The user makes a selection and the answer/s are shown.
I have some code which counts the amount of records and then either displays an error message or shows the products.
What I would like to do is work out if there is only 1 record and what the name of the 1 serial number is for that record.
EG, my database has 2 columns
ID and SerialNumber
Simply put, my ideal code would be
If there is only 1 record, then get the SerialNumber. Then, Redirect to www. My Serial Number .com
My code so far (Please note it is Line 12 which has the problem):
Code:
int NoOfProducts = ds.Tables["Connectors"].Rows.Count;
int i = 0;
if (NoOfProducts == 0)
{
lbNoOfProducts.Text = "<p>Your search produced no results</p>";
lbNoOfProducts.Visible = true;
}
else if(NoOfProducts == 1)
{
Response.Redirect("http://www.website.com/search.aspx?pn="+Eval("PartNumber")+"");
}
else
{
lbNoOfProducts.Text = "<p>Displaying " + NoOfProducts + " products</p>";
lbNoOfProducts.Visible = true;
if (ds.Tables["Connectors"].Rows[0]["PartNumber"] != "")
{
string strPartNumber = (Convert.ToString(ds.Tables["Connectors"].Rows[0]["PartNumber"]));
}
}
How do I just read this value from the databse and insert it into (line12)?
Thanks
Dave
Comment