Are you sure that Access database do have got a
PDTID
column?
I'd change this:
SELECT * from Products where PDTID=?
to:
SELECT * from Products AS P where P.PDTID=?
You have to be warned about
SqlInjection. So, i'd use
OledbCommand[
^] with parameters!
[EDIT]
I'd simplify your code to this:
string sConn = @"Provider=Microsoft.Ace.OLEDB.12.0;Data Source=C:\Users\computer\Documents\Visual Studio 2010\WebSites\WebSite3\Shop.accdb;Persist Security Info =False;";
DataTable dt = new DataTable();
int pdtid = Request["id"];
string sComm = "SELECT P.* FROM Products AS P WHERE P.PDTID=?;";
using (OleDbConnection oConn = new OleDbConnection(sConn))
{
oConn.Open();
using (OleDbCommand oComm = new OleDbCommand(sComm, oConn))
{
oComm.Parameters.Add(new OleDbParameter(){Value=pdtid});
using (OleDbDataReader oRdr = oComm.ExecuteReader())
{
dt.Load(oRdr);
}
}
}
if(dt.Rows.Count>0)
{
DataColumn dc = new DataColumn("TotalPrice", typeof(double));
dc.Expression = "PRICE * QUANTITY";
dt.Columns.Add(dc);
GridView1.DataSource = dt;
}
For further details, please see:
DataColumn.Expression Property (System.Data) | Microsoft Docs[
^]