DimmyConAsNewADODB.Connection
DimmyRsAsNewADODB.Recordset
PrivateSubCommand1_Click()
Dimxm,xh,xb,nl,xy,dh,dzAsString
xm=Text1.Text
xh=Text2.Text
xb=Text3.Text
nl=Text4.Text
xy=Text5.Text
dh=Text6.Text
dz=Text7.Text
myCon.Open\"Provider=Microsoft.Jet.OLEDB.4.0;DataSource=C:\\Users\\Administrator\\Desktop\\数据库\\信息表.mdb;\"
myRs.Open\"select*from学生信息表where姓名=\'\"defds123Trim(Text1.Text)defds123\"\'and学号=\'\"defds123Trim(Text2.Text)defds123\"\'\",myCon
IfmyRs.EOF=FalseThen
MsgBox\"该学生档案已经存在,请重新输入!\"
myRs.Close
myCon.Close
Text1.SetFocus
ExitSub
EndIf
Adodc1.Close
Adodc1.Open\"学生信息表\",myCon,3,2
Adodc1.AddNew
Adodc1.Fields(\"姓名\")=texe1.Text
Adodc1.Fields(\"学号\")=texe2.Text
Adodc1.Fields(\"性别\")=texe3.Text
Adodc1.Fields(\"年龄\")=texe4.Text
Adodc1.Fields(\"学院\")=texe5.Text
Adodc1.Fields(\"电话\")=texe6.Text
Adodc1.Fields(\"地址\")=texe7.Text
Adodc1.Update
Adodc1.Close
myCon.Close
MsgBox\"添加成功!\"
Adodc1.RecordSource=\"select*from学生信息表orderby学号\"
Frm_AddDangA.Adodc1.Refresh
Frm_AddDangA.DataGrid1.Refresh
EndSub
|