小弟做的是毕业设计..急需解决.多谢各位的搭救..是这样的,我开发环境是在DW中用.NET+VB动态技术...数据库是ACCESS..
做到购物车时出错..购物车是用一个临时表装的..请看下面代码:
<script runat="server">
Dim Cpbt As DataTable
Dim Cpview as DataView
Sub CrCpdatatable()
Cpbt = New DataTable()
Cpbt.Columns.Add(new DataColumn("商品编号",GetType(long)))
Cpbt.Columns.Add(new DataColumn("商品名称",GetType(String)))
Cpbt.Columns.Add(new DataColumn("价格",GetType(single)))
Cpbt.Columns.Add(new DataColumn("数量",GetType(Int32)))
Cpbt.Columns.Add(new DataColumn("小计",GetType(double)))
End Sub
Sub AddCpbt()
Dim cpConn,Cpstring AS String
Dim conn AS OleDbConnection
Dim Cpadapter AS OleDbDataAdapter
Dim Cpdat AS DataSet
Dim dt AS DataTable
cpConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.MapPath ("dat/shop.mdb")
conn = New OledbConnection(cpConn)
Cpstring = "SELECT 商品编号,商品名称,价格 from Goods WHERE 商品编号='"& Trim(Request.QueryString("商品编号")) &" '"
Cpadapter = new OleDbDataAdapter(Cpstring,conn)
Cpdat = New DataSet()
Cpadapter.Fill(Cpdat,"Goods")
dt = Cpdat.Tables("Goods")
Dim dr As DataRow = Cpbt.NewRow()
dr(0) = dt.Rows(0)("商品编号")
dr(1) = dt.Rows(0)("商品名称")
dr(2) = dt.Rows(0)("价格")
dr(3) = 1
dr(4) = dr(2) * dr(3)
Cpbt.Rows.Add(dr)
End Sub
Sub CpTotal()'用于统计财物车总金额
Dim i As Integer
Dim Cpto As single=0
For i=0 to Cpbt.Rows.Count-1
Cpto=Cpto+Cpbt.Rows(i)(4)
Next
CPCOUNT.text=Cpto
End Sub Sub ByGrid_Delete(sender As Object, e As DataGridCommandEventArgs)'用于删除当前购物
Dim dr As DataRow = Cpbt.NewRow()
Dim itemCell As TableCell = e.Item.Cells(0)
Dim item As String = ItemCell.Text
CpView.RowFilter = "商品编号='" & item & "'"
If CpView.Count > 0 Then
CpView.Delete(0)
End If
CpView.RowFilter = ""
CpTotal
ByGrid.DataSource = CpView
ByGrid.DataBind()
End Sub Sub CpUpdate_Click(sender As object, e As EventArgs)
Dim i,j As Integer
Dim _item As DataGridItem
j=0
For i=0 To ByGrid.Items.Count-1
_item = ByGrid.Items(i)
Dim CountText As TextBox = _item.FindControl("Sltxt")
Cpbt.Rows(i)(3) = CountText.Text
Cpbt.Rows(i)(4) = Cpbt.Rows(i)(2) * Cpbt.Rows(i)(3)
Next
CpTotal
ByGrid.DataSource = New DataView(Cpbt)
ByGrid.DataBind()
End Sub Sub ClearBy_Click(sender As object, e As EventArgs)
Dim i As Integer
For i=0 to CpView.Count-1
CpView.Delete(i)
Next
CPCOUNT.text=0
CpView.RowFilter = ""
ByGrid.DataSource = CpView
ByGrid.DataBind()
End Sub
Sub Page_Load(Sender As Object,e As EventArgs)
If Session("Cpshop") Is Nothing Then
CrCpdatatable
Session("Cpshop") = Cpbt
Else
Cpbt = Session("shop")
End If
Cpview = New DataView(Cpbt)
If (Not IsPostBack) Then
If Session("UserID")="" or Session("UserID")=nothing Then
response.Redirect("nologin.htm")
End If
AddCpbt
CpTotal
ByGrid.DataSource = Cpview
ByGrid.DataBind()
End If
End Sub
</script>它提示"Cpadapter.Fill(Cpdat,"Goods")"这句错误...
说标准表达式中数据类型不匹配!这是怎么因事啊...
做到购物车时出错..购物车是用一个临时表装的..请看下面代码:
<script runat="server">
Dim Cpbt As DataTable
Dim Cpview as DataView
Sub CrCpdatatable()
Cpbt = New DataTable()
Cpbt.Columns.Add(new DataColumn("商品编号",GetType(long)))
Cpbt.Columns.Add(new DataColumn("商品名称",GetType(String)))
Cpbt.Columns.Add(new DataColumn("价格",GetType(single)))
Cpbt.Columns.Add(new DataColumn("数量",GetType(Int32)))
Cpbt.Columns.Add(new DataColumn("小计",GetType(double)))
End Sub
Sub AddCpbt()
Dim cpConn,Cpstring AS String
Dim conn AS OleDbConnection
Dim Cpadapter AS OleDbDataAdapter
Dim Cpdat AS DataSet
Dim dt AS DataTable
cpConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.MapPath ("dat/shop.mdb")
conn = New OledbConnection(cpConn)
Cpstring = "SELECT 商品编号,商品名称,价格 from Goods WHERE 商品编号='"& Trim(Request.QueryString("商品编号")) &" '"
Cpadapter = new OleDbDataAdapter(Cpstring,conn)
Cpdat = New DataSet()
Cpadapter.Fill(Cpdat,"Goods")
dt = Cpdat.Tables("Goods")
Dim dr As DataRow = Cpbt.NewRow()
dr(0) = dt.Rows(0)("商品编号")
dr(1) = dt.Rows(0)("商品名称")
dr(2) = dt.Rows(0)("价格")
dr(3) = 1
dr(4) = dr(2) * dr(3)
Cpbt.Rows.Add(dr)
End Sub
Sub CpTotal()'用于统计财物车总金额
Dim i As Integer
Dim Cpto As single=0
For i=0 to Cpbt.Rows.Count-1
Cpto=Cpto+Cpbt.Rows(i)(4)
Next
CPCOUNT.text=Cpto
End Sub Sub ByGrid_Delete(sender As Object, e As DataGridCommandEventArgs)'用于删除当前购物
Dim dr As DataRow = Cpbt.NewRow()
Dim itemCell As TableCell = e.Item.Cells(0)
Dim item As String = ItemCell.Text
CpView.RowFilter = "商品编号='" & item & "'"
If CpView.Count > 0 Then
CpView.Delete(0)
End If
CpView.RowFilter = ""
CpTotal
ByGrid.DataSource = CpView
ByGrid.DataBind()
End Sub Sub CpUpdate_Click(sender As object, e As EventArgs)
Dim i,j As Integer
Dim _item As DataGridItem
j=0
For i=0 To ByGrid.Items.Count-1
_item = ByGrid.Items(i)
Dim CountText As TextBox = _item.FindControl("Sltxt")
Cpbt.Rows(i)(3) = CountText.Text
Cpbt.Rows(i)(4) = Cpbt.Rows(i)(2) * Cpbt.Rows(i)(3)
Next
CpTotal
ByGrid.DataSource = New DataView(Cpbt)
ByGrid.DataBind()
End Sub Sub ClearBy_Click(sender As object, e As EventArgs)
Dim i As Integer
For i=0 to CpView.Count-1
CpView.Delete(i)
Next
CPCOUNT.text=0
CpView.RowFilter = ""
ByGrid.DataSource = CpView
ByGrid.DataBind()
End Sub
Sub Page_Load(Sender As Object,e As EventArgs)
If Session("Cpshop") Is Nothing Then
CrCpdatatable
Session("Cpshop") = Cpbt
Else
Cpbt = Session("shop")
End If
Cpview = New DataView(Cpbt)
If (Not IsPostBack) Then
If Session("UserID")="" or Session("UserID")=nothing Then
response.Redirect("nologin.htm")
End If
AddCpbt
CpTotal
ByGrid.DataSource = Cpview
ByGrid.DataBind()
End If
End Sub
</script>它提示"Cpadapter.Fill(Cpdat,"Goods")"这句错误...
说标准表达式中数据类型不匹配!这是怎么因事啊...
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货