vb语句翻译在线等im strsql As StringOn Error GoTo ErrMsg '判断数据的正确性 If Trim(txt(0)) = "" Or Trim(txt(1)) = "" Or Trim(txt(2)) = "" Or Trim(txt(2)) = "" Or Trim(txt(3)) = "" Or Trim(txt(4)) = "" Or Trim(txt(5)) = "" Or Trim(
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/08 14:53:54
vb语句翻译在线等im strsql As StringOn Error GoTo ErrMsg '判断数据的正确性 If Trim(txt(0)) = "" Or Trim(txt(1)) = "" Or Trim(txt(2)) = "" Or Trim(txt(2)) = "" Or Trim(txt(3)) = "" Or Trim(txt(4)) = "" Or Trim(txt(5)) = "" Or Trim(
vb语句翻译在线等
im strsql As String
On Error GoTo ErrMsg
'判断数据的正确性
If Trim(txt(0)) = "" Or Trim(txt(1)) = "" Or Trim(txt(2)) = "" Or Trim(txt(2)) = "" Or Trim(txt(3)) = "" Or Trim(txt(4)) = "" Or Trim(txt(5)) = "" Or Trim(txt(6)) = "" Or Trim(txt(7)) = "" Or Trim(txt(8)) = "" Then
MsgBox "添加的值不能为空!", vbInformation, MSGTITLE
Exit Sub
End If
'打开连接并执行语句
Set cnn = New ADODB.Connection
If cnn.State = 1 Then cnn.Close
cnn.ConnectionString = Business_ConnStr
If cnn.State = 0 Then cnn.Open
strsql = "insert into 论文信息(论文编号,论文题目,论文年度,论文摘要,论文作者,论文分类,所属院校,所属教研室,指导教师,指导教师电话) " _
+ "values('" + Trim(txt(0).Text) + "','" + Trim(txt(1).Text) + "','" + Trim(txt(2).Text) + "','" + Trim(txt(3).Text) + "','" + Trim(txt(4).Text) + "','" + Trim(Combo1(0).Text) + "', '" + Trim(txt(5).Text) + "','" + Trim(txt(6).Text) + "','" + Trim(txt(7).Text) + "','" + Trim(txt(8).Text) + "')"
Debug.Print strsql
cnn.Execute (strsql)
cnn.Close
'重新绑定控件
Call RefreshTypeList
adc_xgsj.Recordset.MoveLast
MsgBox "添加记录成功!", vbInformation, MSGTITLE
Exit Sub
ErrMsg:
MsgBox "数据库操作出错!请联系系统管理员!", vbInformation, MSGTITLE
End Sub
vb语句翻译在线等im strsql As StringOn Error GoTo ErrMsg '判断数据的正确性 If Trim(txt(0)) = "" Or Trim(txt(1)) = "" Or Trim(txt(2)) = "" Or Trim(txt(2)) = "" Or Trim(txt(3)) = "" Or Trim(txt(4)) = "" Or Trim(txt(5)) = "" Or Trim(
这是一段ADODB代码,作用是向数据库中写入数据.
首先是判断输入数据的有效性(是有为空),之后打开一个连接对象与数据库进行连接,写一段SQL语句,打印在界面,然后执行,最后关闭对象(奇怪的是这么没清空记录集)~之后调用一个RefreshTypeList过程,让adc_xgsj这个记录集移动到最后一条记录.一个MSGBOX提示添加完成~.
最后ERRMSG是一段出错提示代码.
这个过程就结束了.
还有不懂得可以问我,