计算库存表中产品剩余数量(小弟我写的语句,不知到哪里错,请帮忙看看)
计算库存表中产品剩余数量(我写的语句,不知到哪里错,请各位高手帮忙看看)
销售表:产品名称 规格型号 销售数量 购买者姓名
产品表:产品名称 规格型号 产品总数量
库存表:产品数量 规格型号 产品剩余数量
计算库存表中产品剩余数量
下面是我写的语句,不知到哪里错,请各位高手帮忙看看
Dim Conn As new OLEDBConnection()
Conn.ConnectionString="provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("..\data\lygms.mdb")
Conn.open()
Dim sql As string ="select sum(销售数量) from销售表Where 产品名称='" & a.text & "' and 规格型号='" &b.text & "'"
Dim Cmd As New OleDbCommand(sql,Conn)
dim reader as OleDbDataReader = Cmd.ExecuteReader()
Dim objAdpt As New OleDbDataAdapter(sql,Conn)
Dim DS As New DataSet()
objAdpt.Fill(DS, "销售表")
Dim myTable As DataTable = DS.Tables("销售表")
Dim sql1 As string ="select sum(产品总数量from产品表Where 产品名称='" & a.text & "' and 规格型号='" & b.text & "'"
Dim Cmd1 As New OleDbCommand(sql1,Conn)
dim reader1 as OleDbDataReader = Cmd1.ExecuteReader()
Dim objAdpt1 As New OleDbDataAdapter(sql1,Conn)
Dim DS1 As New DataSet()
objAdpt1.Fill(DS1,"产品表")
Dim myTable1 As DataTable = DS1.Tables("产品表")
if mytable.rows.count>0 and mytable1.rows.count>0 and mytable1.rows.count>0 and reader.read()=true and reader1.read()=true then
dim a as long=myTable.rows.item(0)
dim b as long=myTable1.rows.item(0)
dim c as long=b-a
Dim sql As string ="select产品名称,规格型号 from库存表Where 产品名称='" & a.text & "' and 规格型号='" &b.text & "'"
Dim Cmd3 As New OleDbCommand(sql3,Conn)
dim reader3 as OleDbDataReader = Cmd3.ExecuteReader()
if reader3.read=true then
Dim strSQL1 As String = "Update 库存表 Set 产品名称='" & a.text & "',规格型号='" & b.text & "', 产品剩余数量='" & c & "' Where 产品名称='" & a.text & "',规格型号='" & b.text & "'"
Dim objCmd As New OLEDBCommand(strSQL1, Conn)
objCmd.ExecuteNonQuery()
Else
Dim strSQL2 As String ="Insert Into 库存(产品名称,规格型号, 产品剩余数量) Values ('"& a.text & "','"& btext & "','" & c & "')"
Dim objCmd 1As New OLEDBCommand(strSQL2, Conn)
objCmd1.ExecuteNonQuery()
end if
else response(“错误!”)
end if
------解决方案--------------------
楼主这个是vb.net的语法吧,这是VB版啊
------解决方案--------------------
哪行报错,有什么错误提示
------解决方案--------------------
"', 产品剩余数量='" & c & "' Where 产品名称='"
产品剩余数量 应该是数值类型吧,不要用带单引号的字符串值。
------解决方案--------------------
dim a as long
a=myTable.rows.item(0)
下同.
------解决方案--------------------
Dim sql1 As string ="select sum(产品总数量from产品表Where 产品名称='" & a.text & "' and 规格型号='" & b.text & "'"
这句求和只看到一个( ,少写了 ) ? 其它的一下看不出来,顶上去~~
------解决方案--------------------
销售表:产品名称 规格型号 销售数量 购买者姓名
产品表:产品名称 规格型号 产品总数量
库存表:产品数量 规格型号 产品剩余数量
计算库存表中产品剩余数量
下面是我写的语句,不知到哪里错,请各位高手帮忙看看
Dim Conn As new OLEDBConnection()
Conn.ConnectionString="provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("..\data\lygms.mdb")
Conn.open()
Dim sql As string ="select sum(销售数量) from销售表Where 产品名称='" & a.text & "' and 规格型号='" &b.text & "'"
Dim Cmd As New OleDbCommand(sql,Conn)
dim reader as OleDbDataReader = Cmd.ExecuteReader()
Dim objAdpt As New OleDbDataAdapter(sql,Conn)
Dim DS As New DataSet()
objAdpt.Fill(DS, "销售表")
Dim myTable As DataTable = DS.Tables("销售表")
Dim sql1 As string ="select sum(产品总数量from产品表Where 产品名称='" & a.text & "' and 规格型号='" & b.text & "'"
Dim Cmd1 As New OleDbCommand(sql1,Conn)
dim reader1 as OleDbDataReader = Cmd1.ExecuteReader()
Dim objAdpt1 As New OleDbDataAdapter(sql1,Conn)
Dim DS1 As New DataSet()
objAdpt1.Fill(DS1,"产品表")
Dim myTable1 As DataTable = DS1.Tables("产品表")
if mytable.rows.count>0 and mytable1.rows.count>0 and mytable1.rows.count>0 and reader.read()=true and reader1.read()=true then
dim a as long=myTable.rows.item(0)
dim b as long=myTable1.rows.item(0)
dim c as long=b-a
Dim sql As string ="select产品名称,规格型号 from库存表Where 产品名称='" & a.text & "' and 规格型号='" &b.text & "'"
Dim Cmd3 As New OleDbCommand(sql3,Conn)
dim reader3 as OleDbDataReader = Cmd3.ExecuteReader()
if reader3.read=true then
Dim strSQL1 As String = "Update 库存表 Set 产品名称='" & a.text & "',规格型号='" & b.text & "', 产品剩余数量='" & c & "' Where 产品名称='" & a.text & "',规格型号='" & b.text & "'"
Dim objCmd As New OLEDBCommand(strSQL1, Conn)
objCmd.ExecuteNonQuery()
Else
Dim strSQL2 As String ="Insert Into 库存(产品名称,规格型号, 产品剩余数量) Values ('"& a.text & "','"& btext & "','" & c & "')"
Dim objCmd 1As New OLEDBCommand(strSQL2, Conn)
objCmd1.ExecuteNonQuery()
end if
else response(“错误!”)
end if
------解决方案--------------------
楼主这个是vb.net的语法吧,这是VB版啊
------解决方案--------------------
哪行报错,有什么错误提示
------解决方案--------------------
"', 产品剩余数量='" & c & "' Where 产品名称='"
产品剩余数量 应该是数值类型吧,不要用带单引号的字符串值。
------解决方案--------------------
dim a as long
a=myTable.rows.item(0)
下同.
------解决方案--------------------
Dim sql1 As string ="select sum(产品总数量from产品表Where 产品名称='" & a.text & "' and 规格型号='" & b.text & "'"
这句求和只看到一个( ,少写了 ) ? 其它的一下看不出来,顶上去~~
------解决方案--------------------