在Vb中添加数据信息到连接的数据库中,当判断添加的数据主键是否已经存在时,出现代码错误!
PrivateSubCommand4_Click()Adodc1.RecordSource="select*from销售订单明细表"IfText1.Text=""Then...
Private Sub Command4_Click()
Adodc1.RecordSource = "select * from 销售订单明细表"
If Text1.Text = "" Then
MsgBox "订单号不能为空"
Else
If Adodc1.Recordset.RecordCount > 0 Then
MsgBox "该信息已经存在,不能再保存!"
Else
Adodc1.Recordset.AddNew
Adodc1.Recordset.Fields("订单号") = Text1.Text
Adodc1.Recordset.Fields("产品代码") = Text10.Text
Adodc1.Recordset.Fields("产品名称") = Text2.Text
Adodc1.Recordset.Fields("产品单价") = Val(Text3)
Adodc1.Recordset.Fields("顾客编号") = Text4.Text
Adodc1.Recordset.Fields("订货时间") = Text5.Text
Adodc1.Recordset.Fields("发货时间") = Text6.Text
Adodc1.Recordset.Fields("发货数量") = Val(Text7)
Adodc1.Recordset.Fields("折扣等级") = Val(Text8)
Adodc1.Recordset.Fields("折后金额") = Val(Text9)
Adodc1.Recordset.Fields("付款方式") = Combo1.Text
Adodc1.Recordset.Fields("进度") = Combo2.Text
End If
End If
End Sub 展开
Adodc1.RecordSource = "select * from 销售订单明细表"
If Text1.Text = "" Then
MsgBox "订单号不能为空"
Else
If Adodc1.Recordset.RecordCount > 0 Then
MsgBox "该信息已经存在,不能再保存!"
Else
Adodc1.Recordset.AddNew
Adodc1.Recordset.Fields("订单号") = Text1.Text
Adodc1.Recordset.Fields("产品代码") = Text10.Text
Adodc1.Recordset.Fields("产品名称") = Text2.Text
Adodc1.Recordset.Fields("产品单价") = Val(Text3)
Adodc1.Recordset.Fields("顾客编号") = Text4.Text
Adodc1.Recordset.Fields("订货时间") = Text5.Text
Adodc1.Recordset.Fields("发货时间") = Text6.Text
Adodc1.Recordset.Fields("发货数量") = Val(Text7)
Adodc1.Recordset.Fields("折扣等级") = Val(Text8)
Adodc1.Recordset.Fields("折后金额") = Val(Text9)
Adodc1.Recordset.Fields("付款方式") = Combo1.Text
Adodc1.Recordset.Fields("进度") = Combo2.Text
End If
End If
End Sub 展开
展开全部
Private Sub Command4_Click()
If Text1.Text = "" Then
MsgBox "订单号肢高不能为空困毁"
Else
Adodc1.RecordSource = "select * from 销售订单明细表 where 订单号='" & Text1.Text & "'"
If Adodc1.Recordset.RecordCount > 0 Then
MsgBox "该信息已经存在,不能再保存!"
Else
Adodc1.Recordset.AddNew
Adodc1.Recordset.Fields("汪饥备订单号") = Text1.Text
Adodc1.Recordset.Fields("产品代码") = Text10.Text
Adodc1.Recordset.Fields("产品名称") = Text2.Text
Adodc1.Recordset.Fields("产品单价") = Val(Text3)
Adodc1.Recordset.Fields("顾客编号") = Text4.Text
Adodc1.Recordset.Fields("订货时间") = Text5.Text
Adodc1.Recordset.Fields("发货时间") = Text6.Text
Adodc1.Recordset.Fields("发货数量") = Val(Text7)
Adodc1.Recordset.Fields("折扣等级") = Val(Text8)
Adodc1.Recordset.Fields("折后金额") = Val(Text9)
Adodc1.Recordset.Fields("付款方式") = Combo1.Text
Adodc1.Recordset.Fields("进度") = Combo2.Text
Adodc1.Recordset.Update
End If
End If
End Sub
If Text1.Text = "" Then
MsgBox "订单号肢高不能为空困毁"
Else
Adodc1.RecordSource = "select * from 销售订单明细表 where 订单号='" & Text1.Text & "'"
If Adodc1.Recordset.RecordCount > 0 Then
MsgBox "该信息已经存在,不能再保存!"
Else
Adodc1.Recordset.AddNew
Adodc1.Recordset.Fields("汪饥备订单号") = Text1.Text
Adodc1.Recordset.Fields("产品代码") = Text10.Text
Adodc1.Recordset.Fields("产品名称") = Text2.Text
Adodc1.Recordset.Fields("产品单价") = Val(Text3)
Adodc1.Recordset.Fields("顾客编号") = Text4.Text
Adodc1.Recordset.Fields("订货时间") = Text5.Text
Adodc1.Recordset.Fields("发货时间") = Text6.Text
Adodc1.Recordset.Fields("发货数量") = Val(Text7)
Adodc1.Recordset.Fields("折扣等级") = Val(Text8)
Adodc1.Recordset.Fields("折后金额") = Val(Text9)
Adodc1.Recordset.Fields("付款方式") = Combo1.Text
Adodc1.Recordset.Fields("进度") = Combo2.Text
Adodc1.Recordset.Update
End If
End If
End Sub
追问
恩,不能用呢,不管输入的订单号是否重复,都会有消息盒子报错说订单号已经存在,,,,能否再帮我改改。。。。
追答
加百度HI 发文件过来吧
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询