Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx thread: Returning the single field as String in Select Statement


Message #1 by "Mel C Solomon" <melsolomon@e...> on Sat, 18 Aug 2001 18:36:36 -0800
Hello,



I am following the IbuySpy store codes and i use MS Access2000 as back 

end. I'm having problem getting computing/getting the "Total" price.



Here is the Label control that should contain the result of GetTotal method.



lblTotal.Text = String.Format( "{0:c}", GetTotal(cartID));



and here is the method (this is incorrect,don't mind the syntax error):

-------------------

public string GetTotal(string cartID) {



string strconn="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Server.MapPath(".//db//db1.mdb");

OleDbConnection myConnection = new OleDbConnection(strconn);

myConnection.Open();

string strgettotal ="Select SUM(c.productQuantity * p.productCost) as Total FROM products p, cart c WHERE
c.cartID='"+cartID.ToString()+"' and p.productID=c.productID" ;

OleDbCommand myCommand = new OleDbCommand(strgettotal, myConnection);	   

OleDbDataReader myreader=myCommand.ExecuteReader(CommandBehavior.CloseConnection);

	     	

return Total; //-->I want to return the Total field, how?



}

------------------



Any recommendation/suggestion/comments/help/ appreciated.



Thanks,

mel :-)





__________________________________

www.edsamail.com


  Return to Index