VB编程问题:在Vb中添加数据信息到连接的数据库中,当判断添加的数据主键是否已经存在时,出现代码错误!
哪位编程高手帮我改改啊,小女子不甚感激。代码如下:PrivateSubCommand4_Click()Adodc1.RecordSource="select*from销售...
哪位编程高手帮我改改啊,小女子不甚感激。代码如下:
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 展开
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 展开
2个回答
展开全部
End If
Dim s As String, d As String, X As String
If App.Path + "\Ver.ini" = "" Or App.Path + "\updata.ini" = "" Then MsgBox "其中1个不存在": Exit Sub
Open App.Path + "\Ver.ini" For Input As #1
Do While Not EOF(1)
Line Input #1, s
d = d & s & vbCrLf
Loop
Close #1
Open App.Path + "\updata.ini" For Input As #1
Do While Not EOF(1)
Line Input #1, s
X = X & s & vbCrLf
Loop
Close #1
If d <> X Then
Dim s As String, d As String, X As String
If App.Path + "\Ver.ini" = "" Or App.Path + "\updata.ini" = "" Then MsgBox "其中1个不存在": Exit Sub
Open App.Path + "\Ver.ini" For Input As #1
Do While Not EOF(1)
Line Input #1, s
d = d & s & vbCrLf
Loop
Close #1
Open App.Path + "\updata.ini" For Input As #1
Do While Not EOF(1)
Line Input #1, s
X = X & s & vbCrLf
Loop
Close #1
If d <> X Then
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询