地狱之眼宫本武藏视频:急 VB中 SQL execute 的问题

来源:百度文库 编辑:高校问答 时间:2024/05/05 09:14:23
If xs = 0 Then
'添加资料
sqls = "select * from 学生档案 where 学号='" & id & "'"
RS.Open sqls, CONN, 1, 1
If Not RS.EOF Then
MsgBox "已经存在学号为" & id & "的学生资料,请重新输入!", vbInformation
Combo2.SetFocus
RS.Close: Set RS = Nothing ("此句有无都是一样不行")
Exit Sub
End If
RS.Close: Set RS = Nothing

sqls = "insert into 学生档案(学号,姓名,性别,民族,生日,政治面貌,籍贯,邮政编码,家庭住址,备注,班级,联系电话,专业)"
sqls = sqls & "values('" & id & "','" & Text1.Text & "','" & Combo3.Text & "',"
sqls = sqls & "'" & Combo4.Text & "','" & DTPicker1.Value & "','" & Combo5.Text & "','" & Text2.Text & "','" & Text4.Text & "',"
sqls = sqls & "'" & Text5.Text & "','" & Text6.Text & "','" & classid & "','" & Text3.Text & "','" & zy & "')"

Else
'修改资料
sqls = "update 学生档案 set 学号='" & id & "', 专业='" & zy & "', 姓名='" & Text1.Text & "',性别='" & Combo3.Text & "',联系电话='" & Text3.Text & "',"
sqls = sqls & "民族='" & Combo4.Text & "',生日='" & DTPicker1.Value & "',政治面貌='" & Combo5.Text & "',籍贯='" & Text2.Text & "',"
sqls = sqls & "邮政编码='" & Text4.Text & "',家庭住址='" & Text5.Text & "',备注='" & Text6.Text & "',班级='" & classid & "' "

End If

CONN.Execute sqls

修改资料的地方 本针对一个数据做修改的 但是修改后 把所有的数据都给改了
该问题已解决