首页上一页 1 下一页尾页 1 条记录 1/1页
大侠帮忙看下,问题出在那了?
发表在VB答疑区
2008-08-02
是否精华
是
否
版块置顶:
是
否
大侠们看下是那错了
在增加或修改时出现错误,代码提示的位置我在代码后面标明.
Private Sub cmdSave_Click()
Dim A As Long
If blnAddRS = False Then
A = MsgBox("您确实要修改这条数据吗?", vbYesNo)
If A = vbYes Then
rs1.Open "select * from 人事表 where 编号='" + Txt1(0).text + "'", Cnn, adOpenKeyset, adLockOptimistic
If rs1.RecordCount > 0 Then
rs1.Fields("编号") = Txt1(0)
rs1.Fields("姓名") = Txt1(1)
rs1.Fields("性别") = Combo1.text
rs1.Fields("身份证号") = Txt1(2)
rs1.Fields("出生年月") = DTP1.Value
rs1.Fields("年龄") = Txt1(17)
rs1.Fields("民族") = DataCombo1
rs1.Fields("婚姻状况") = Combo2 (在些会出现错误提示)
rs1.Fields("政治面貌") = DataCombo2 (在些会出现错误提示)
rs1.Fields("入党团时间") = DTP2.Value
rs1.Fields("籍贯") = Txt1(3)
rs1.Fields("联系电话") = Txt1(4)
rs1.Fields("手机号码") = Txt1(5)
rs1.Fields("家庭地址") = Txt1(6)
rs1.Fields("毕业院校") = Txt1(7)
rs1.Fields("专业") = Txt1(8)
rs1.Fields("文化程度") = DataCombo3
rs1.Fields("特长") = Txt1(9)
rs1.Fields("参加工作时间") = DTP3.Value
rs1.Fields("总工龄") = Val(Txt1(10))
mst.Type = adTypeBinary
mst.Open
If photoFilename <> "" Then mst.LoadFromFile photoFilename
rs1.Fields("照片") = mst.Read
rs1.Fields("部门") = Txt1(11)
rs1.Fields("工种") = DataCombo4
rs1.Fields("职务") = DataCombo5
rs1.Fields("职称") = DataCombo6
rs1.Fields("基本工资") = Val(Txt1(12))
rs1.Fields("其它工资") = Val(Txt1(13))
rs1.Fields("调入时间") = DTP4.Value
rs1.Fields("本单位工龄") = Val(Txt1(14))
rs1.Fields("简历") = Txt1(15)
rs1.Fields("登记日期") = DTP5.Value
rs1.Fields("登记人") = Txt1(16)
rs1.Update
main_rsgl_rsdaxx.Adodc1.Refresh
End If
rs1.Close
mst.Close
End If
Else
If Txt1(1).text = "" Then
MsgBox "姓名不允许为空!"
Exit Sub
End If
rs1.Open "select * from 人事表", Cnn, adOpenKeyset, adLockOptimistic
'新增人员
rs1.AddNew
rs1.Fields("编号") = Txt1(0)
rs1.Fields("姓名") = Txt1(1)
rs1.Fields("性别") = Combo1.text
rs1.Fields("身份证号") = Txt1(2)
rs1.Fields("出生年月") = DTP1.Value
rs1.Fields("年龄") = Txt1(17)
rs1.Fields("民族") = DataCombo1
rs1.Fields("婚姻状况") = Combo2 (在些会出现错误提示)
rs1.Fields("政治面貌") = DataCombo2 (在些会出现错误提示)
rs1.Fields("入党团时间") = DTP2.Value
rs1.Fields("籍贯") = Txt1(3)
rs1.Fields("联系电话") = Txt1(4)
rs1.Fields("手机号码") = Txt1(5)
rs1.Fields("家庭地址") = Txt1(6)
rs1.Fields("毕业院校") = Txt1(7)
rs1.Fields("专业") = Txt1(8)
rs1.Fields("文化程度") = DataCombo3
rs1.Fields("特长") = Txt1(9)
rs1.Fields("参加工作时间") = DTP3.Value
rs1.Fields("总工龄") = Val(Txt1(10))
mst.Type = adTypeBinary
mst.Open
If photoFilename <> "" Then mst.LoadFromFile photoFilename
rs1.Fields("照片") = mst.Read
rs1.Fields("部门") = Txt1(11)
rs1.Fields("工种") = DataCombo4
rs1.Fields("职务") = DataCombo5
rs1.Fields("职称") = DataCombo6
rs1.Fields("基本工资") = Val(Txt1(12))
rs1.Fields("其它工资") = Val(Txt1(13))
rs1.Fields("调入时间") = DTP4.Value
rs1.Fields("本单位工龄") = Val(Txt1(14))
rs1.Fields("简历") = Txt1(15)
rs1.Fields("登记日期") = DTP5.Value
rs1.Fields("登记人") = Txt1(16)
rs1.Update
main_rsgl_rsdaxx.Adodc1.Refresh
rs1.Close
mst.Close
End If
Unload Me
End Sub
在增加或修改时出现错误,代码提示的位置我在代码后面标明.
Private Sub cmdSave_Click()
Dim A As Long
If blnAddRS = False Then
A = MsgBox("您确实要修改这条数据吗?", vbYesNo)
If A = vbYes Then
rs1.Open "select * from 人事表 where 编号='" + Txt1(0).text + "'", Cnn, adOpenKeyset, adLockOptimistic
If rs1.RecordCount > 0 Then
rs1.Fields("编号") = Txt1(0)
rs1.Fields("姓名") = Txt1(1)
rs1.Fields("性别") = Combo1.text
rs1.Fields("身份证号") = Txt1(2)
rs1.Fields("出生年月") = DTP1.Value
rs1.Fields("年龄") = Txt1(17)
rs1.Fields("民族") = DataCombo1
rs1.Fields("婚姻状况") = Combo2 (在些会出现错误提示)
rs1.Fields("政治面貌") = DataCombo2 (在些会出现错误提示)
rs1.Fields("入党团时间") = DTP2.Value
rs1.Fields("籍贯") = Txt1(3)
rs1.Fields("联系电话") = Txt1(4)
rs1.Fields("手机号码") = Txt1(5)
rs1.Fields("家庭地址") = Txt1(6)
rs1.Fields("毕业院校") = Txt1(7)
rs1.Fields("专业") = Txt1(8)
rs1.Fields("文化程度") = DataCombo3
rs1.Fields("特长") = Txt1(9)
rs1.Fields("参加工作时间") = DTP3.Value
rs1.Fields("总工龄") = Val(Txt1(10))
mst.Type = adTypeBinary
mst.Open
If photoFilename <> "" Then mst.LoadFromFile photoFilename
rs1.Fields("照片") = mst.Read
rs1.Fields("部门") = Txt1(11)
rs1.Fields("工种") = DataCombo4
rs1.Fields("职务") = DataCombo5
rs1.Fields("职称") = DataCombo6
rs1.Fields("基本工资") = Val(Txt1(12))
rs1.Fields("其它工资") = Val(Txt1(13))
rs1.Fields("调入时间") = DTP4.Value
rs1.Fields("本单位工龄") = Val(Txt1(14))
rs1.Fields("简历") = Txt1(15)
rs1.Fields("登记日期") = DTP5.Value
rs1.Fields("登记人") = Txt1(16)
rs1.Update
main_rsgl_rsdaxx.Adodc1.Refresh
End If
rs1.Close
mst.Close
End If
Else
If Txt1(1).text = "" Then
MsgBox "姓名不允许为空!"
Exit Sub
End If
rs1.Open "select * from 人事表", Cnn, adOpenKeyset, adLockOptimistic
'新增人员
rs1.AddNew
rs1.Fields("编号") = Txt1(0)
rs1.Fields("姓名") = Txt1(1)
rs1.Fields("性别") = Combo1.text
rs1.Fields("身份证号") = Txt1(2)
rs1.Fields("出生年月") = DTP1.Value
rs1.Fields("年龄") = Txt1(17)
rs1.Fields("民族") = DataCombo1
rs1.Fields("婚姻状况") = Combo2 (在些会出现错误提示)
rs1.Fields("政治面貌") = DataCombo2 (在些会出现错误提示)
rs1.Fields("入党团时间") = DTP2.Value
rs1.Fields("籍贯") = Txt1(3)
rs1.Fields("联系电话") = Txt1(4)
rs1.Fields("手机号码") = Txt1(5)
rs1.Fields("家庭地址") = Txt1(6)
rs1.Fields("毕业院校") = Txt1(7)
rs1.Fields("专业") = Txt1(8)
rs1.Fields("文化程度") = DataCombo3
rs1.Fields("特长") = Txt1(9)
rs1.Fields("参加工作时间") = DTP3.Value
rs1.Fields("总工龄") = Val(Txt1(10))
mst.Type = adTypeBinary
mst.Open
If photoFilename <> "" Then mst.LoadFromFile photoFilename
rs1.Fields("照片") = mst.Read
rs1.Fields("部门") = Txt1(11)
rs1.Fields("工种") = DataCombo4
rs1.Fields("职务") = DataCombo5
rs1.Fields("职称") = DataCombo6
rs1.Fields("基本工资") = Val(Txt1(12))
rs1.Fields("其它工资") = Val(Txt1(13))
rs1.Fields("调入时间") = DTP4.Value
rs1.Fields("本单位工龄") = Val(Txt1(14))
rs1.Fields("简历") = Txt1(15)
rs1.Fields("登记日期") = DTP5.Value
rs1.Fields("登记人") = Txt1(16)
rs1.Update
main_rsgl_rsdaxx.Adodc1.Refresh
rs1.Close
mst.Close
End If
Unload Me
End Sub