主题:至少有一个参数没有指定值?急急!!!!!
当程序执行到update时老是弹出至少一个参数没有被指定值,原来没有update那一段代码时一直没出错,不知道是怎么回事,但是update 图书库存表 set 图书数量=(select 图书数量 from 图书库存表) -(select 销售数量 from 销售表) where 图书库存表.ISBN=销售表.ISBN这段代码在SQL编辑器中可以实现,求大家帮帮我,谢谢了!
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim connectionstring As String
Private Sub Combo1_lostfocus()
connectionstring = "Provider=Microsoft.Jet.OLEDB.4.0;data source=" & App.Path & "\图书销售管理系统.mdb"
If conn.State <> 1 Then '连接数据库
conn.Open (connectionstring)
End If
rs.Open "select * from 图书库存表", conn, adOpenStatic, adLockOptimistic, adCmdText
With rs
.MoveFirst
Do While Not .EOF
DoEvents
Text2.Text = .Fields(1)
Text8.Text = .Fields(3)
Text9.Text = .Fields(4)
Text10.Text = .Fields(5)
.MoveNext
Loop
End With
End Sub
Private Sub Command1_Click()
If Combo1.Text = "" Then
If MsgBox("请输入ISBN", vbInformation, "提示") = vbOK Then
Combo1.SetFocus
End If
Else
If Text6.Text = "" Then
If MsgBox("没有折扣吗,请输入折扣", vbInformation, "提示") = vbOK Then
Text6.Text = 1
End If
Else
If Trim(Text4.Text) = "" Then
If MsgBox("请输入单本定价!", vbInformation, "提示!") = vbOK Then
Text4.SetFocus
End If
Else
If Trim(Text3.Text) = "" Then
If MsgBox("请输入销售数量!", vbInformation, "提示!") = vbOK Then
Text3.SetFocus
End If
Else
connectionstring = "Provider=Microsoft.Jet.OLEDB.4.0;data source=" & App.Path & "\图书销售管理系统.mdb"
If conn.State <> 1 Then '连接数据库
conn.Open (connectionstring)
End If
Dim sql As String
sql = "insert into 销售表(出库单编号,ISBN,销售数量,单本定价,总金额,销售折扣,销售日期)" & _
"values('" & Trim(Text1.Text) & "', '" & Trim(Combo1.Text) & "', " & Trim(Text3.Text) & "," & Trim(Text4.Text) & "," _
& Trim(Text5.Text) & "," & Trim(Text6.Text) & ",'" & Trim(Text7.Text) & "')"
conn.Execute (sql)
[b][b]Dim strupdate As String
strupdate = "update 图书库存表 set 图书数量=(select 图书数量 from 图书库存表) -(select 销售数量 from 销售表) where 图书库存表.ISBN=销售表.ISBN"[/b][/b]
connectionstring = "Provider=Microsoft.Jet.OLEDB.4.0;data source=" & App.Path & "\图书销售管理系统.mdb"
If conn.State <> 1 Then
conn.Open (connectionstring)
End If
conn.Execute (strupdate)
conn.Close
'如果没有发生异常就表明插入操作成功,提示用户,然后退出本窗口
If MsgBox("图书销售成功", vbInformation, "提示") = vbOK Then
Unload Me
End If
End If
End If
End If
End If
End Sub
Private Sub Command2_Click()
If MsgBox("真的要取消吗", vbInformation, "提示") = vbOK Then
Unload Me
End If
End Sub
Private Sub Form_Load()
adotsxs.CommandType = adCmdText
adotsxs.RecordSource = "select ISBN from 图书库存表 '设置该窗体的数据源为图书库存表"
adotsxs.Refresh
With adotsxs.Recordset
.MoveFirst
Do While Not .EOF
DoEvents
Combo1.AddItem (!ISBN)
.MoveNext
Loop
End With
adotsxs.RecordSource = "select 货架名称 from 货架表"
adotsxs.Refresh
With adotsxs.Recordset
.MoveFirst
Do While Not .EOF
DoEvents
Combo2.AddItem (!货架名称)
.MoveNext
Loop
End With
adotsxs.RecordSource = "select 出库单编号 from 销售表 order by 出库单编号"
'设置adotsxg的数据源为销售表
adotsxs.Refresh
With adotsxs.Recordset
If .RecordCount > 0 Then
.MoveLast
If !出库单编号 <> 0 Then
Dim bianhao As String
bianhao = Right(Trim(!出库单编号), 3) + 1
Text1.Text = DateTime.Date$ & "p" & Format(bianhao, "000")
End If
Else '如果还没有记录则序号开始为001
Text1.Text = DateTime.Date$ & "p" & "001"
End If
End With
Text7.Text = DateTime.Date$
End Sub
Private Sub Text5_Click()
If Text3.Text <> "" And Text4.Text <> "" And Text6.Text <> "" Then
'只有当两个文本框都输入了内容时才能计算金额
Text5.Text = Trim(Text3.Text) * Trim(Text4.Text) * Text6.Text
End If
Exit Sub
End Sub
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim connectionstring As String
Private Sub Combo1_lostfocus()
connectionstring = "Provider=Microsoft.Jet.OLEDB.4.0;data source=" & App.Path & "\图书销售管理系统.mdb"
If conn.State <> 1 Then '连接数据库
conn.Open (connectionstring)
End If
rs.Open "select * from 图书库存表", conn, adOpenStatic, adLockOptimistic, adCmdText
With rs
.MoveFirst
Do While Not .EOF
DoEvents
Text2.Text = .Fields(1)
Text8.Text = .Fields(3)
Text9.Text = .Fields(4)
Text10.Text = .Fields(5)
.MoveNext
Loop
End With
End Sub
Private Sub Command1_Click()
If Combo1.Text = "" Then
If MsgBox("请输入ISBN", vbInformation, "提示") = vbOK Then
Combo1.SetFocus
End If
Else
If Text6.Text = "" Then
If MsgBox("没有折扣吗,请输入折扣", vbInformation, "提示") = vbOK Then
Text6.Text = 1
End If
Else
If Trim(Text4.Text) = "" Then
If MsgBox("请输入单本定价!", vbInformation, "提示!") = vbOK Then
Text4.SetFocus
End If
Else
If Trim(Text3.Text) = "" Then
If MsgBox("请输入销售数量!", vbInformation, "提示!") = vbOK Then
Text3.SetFocus
End If
Else
connectionstring = "Provider=Microsoft.Jet.OLEDB.4.0;data source=" & App.Path & "\图书销售管理系统.mdb"
If conn.State <> 1 Then '连接数据库
conn.Open (connectionstring)
End If
Dim sql As String
sql = "insert into 销售表(出库单编号,ISBN,销售数量,单本定价,总金额,销售折扣,销售日期)" & _
"values('" & Trim(Text1.Text) & "', '" & Trim(Combo1.Text) & "', " & Trim(Text3.Text) & "," & Trim(Text4.Text) & "," _
& Trim(Text5.Text) & "," & Trim(Text6.Text) & ",'" & Trim(Text7.Text) & "')"
conn.Execute (sql)
[b][b]Dim strupdate As String
strupdate = "update 图书库存表 set 图书数量=(select 图书数量 from 图书库存表) -(select 销售数量 from 销售表) where 图书库存表.ISBN=销售表.ISBN"[/b][/b]
connectionstring = "Provider=Microsoft.Jet.OLEDB.4.0;data source=" & App.Path & "\图书销售管理系统.mdb"
If conn.State <> 1 Then
conn.Open (connectionstring)
End If
conn.Execute (strupdate)
conn.Close
'如果没有发生异常就表明插入操作成功,提示用户,然后退出本窗口
If MsgBox("图书销售成功", vbInformation, "提示") = vbOK Then
Unload Me
End If
End If
End If
End If
End If
End Sub
Private Sub Command2_Click()
If MsgBox("真的要取消吗", vbInformation, "提示") = vbOK Then
Unload Me
End If
End Sub
Private Sub Form_Load()
adotsxs.CommandType = adCmdText
adotsxs.RecordSource = "select ISBN from 图书库存表 '设置该窗体的数据源为图书库存表"
adotsxs.Refresh
With adotsxs.Recordset
.MoveFirst
Do While Not .EOF
DoEvents
Combo1.AddItem (!ISBN)
.MoveNext
Loop
End With
adotsxs.RecordSource = "select 货架名称 from 货架表"
adotsxs.Refresh
With adotsxs.Recordset
.MoveFirst
Do While Not .EOF
DoEvents
Combo2.AddItem (!货架名称)
.MoveNext
Loop
End With
adotsxs.RecordSource = "select 出库单编号 from 销售表 order by 出库单编号"
'设置adotsxg的数据源为销售表
adotsxs.Refresh
With adotsxs.Recordset
If .RecordCount > 0 Then
.MoveLast
If !出库单编号 <> 0 Then
Dim bianhao As String
bianhao = Right(Trim(!出库单编号), 3) + 1
Text1.Text = DateTime.Date$ & "p" & Format(bianhao, "000")
End If
Else '如果还没有记录则序号开始为001
Text1.Text = DateTime.Date$ & "p" & "001"
End If
End With
Text7.Text = DateTime.Date$
End Sub
Private Sub Text5_Click()
If Text3.Text <> "" And Text4.Text <> "" And Text6.Text <> "" Then
'只有当两个文本框都输入了内容时才能计算金额
Text5.Text = Trim(Text3.Text) * Trim(Text4.Text) * Text6.Text
End If
Exit Sub
End Sub