ASP语法错误,急要解决

来源:百度知道 编辑:UC知道 时间:2024/09/24 00:33:31
Protected Sub price()
'创建数据库连接
Dim strConn As String
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;"
strConn &= "Data Source=" + Server.MapPath("Date/shopnet.mdb")
Dim oleDbConn As OleDbConnection
oleDbConn = New OleDbConnection(strConn)

'创建OleDbDataAdapter对象,并填充ds数据集

oleDbConn.Open()
Dim strCmd As String = "select sum(GoodsPrice*GoodsNum) price "
strCmd += "from Shopcar,goodsxinxi"
strCmd += "where goodsxinxi.GoodsId=Shopcar.GoodsId"
strCmd += "and userId='" + Session.Item("userId") + "'"
Dim oleDbCmd As OleDbCommand = oleDbConn.CreateCommand()
oleDbCmd.CommandText = strCmd
Dim oleDbDR As OleDbDataReader = oleDbCmd.ExecuteReader()

If oleDbDR.Read() Then

先两种情况调试一下。一个简单的select看看能不能得到记录。如果有问题,ok你的数据库联接有问题。
如果前面是ok的,那么alert出你的sql 语句直接到数据库里跑,看看是不是有问题。应该很快找到你的问题了