Hi,
I've written the following code to display the total of a shopping basket based on
its CartID. However when I run the page the total displays as zero even though the
database has a value. I thought intially this may have been an issue with the SQL
statement, so I produced it in Access and imported into my file but not
difference. Any ideas why this is failing, which is written in asp.net 1.1and
vb.net, thanks ?
Code:
Function GetTotal() As Decimal
Dim strConnString As String =
ConfigurationSettings.AppSettings.Get("ConnectionString")
strConnString = String.Format(strConnString,
Server.MapPath("\db\nwguitars.mdb"))
Dim dbConnection As System.Data.IDbConnection = New
System.Data.OleDb.OleDbConnection(strConnString)
Dim queryString As String = "SELECT tblTotal.intCartID,
tblTotal.curGrandTotal "& _
"FROM tblTotal WHERE (((tblTotal.intCartID)=5800310022007))"
Dim dbCommand As System.Data.IDbCommand = New
System.Data.OleDb.OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
dbConnection.Open
dbCommand.ExecuteNonQuery()
dbConnection.Close()
End Function
Sub Page_Load
lblCart.Text = 5800310022007
lblTotal.Text = "£ " & GetTotal()
End Sub