求助 关于VB程序中调试
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim Str1 As String
Dim Str2 As String
Dim Str3 As String
Dim strSQL As String
Dim 合格判断 As Long
Dim 采集日期 As Date
Dim 采集时间 As String
Str1 = "Provider=Microsoft.Jet.OLEDB.4.0;"
Str2 = "Data Source=E:\temp1.mdb;"
Str3 = "Jet OLEDB:Database Password="
conn.Open Str1 & Str2 & Str3
strSQL = " tb "
rs.Open strSQL, conn, 3, 3
rs.AddNew
rs!合格判断 = Text2.Text
rs!采集日期 = Text3.Text
rs!采集时间 = Text4.Text
rs.Update
rs.Close
conn.Close
Adodc1.Refresh
End Select
End Sub
各位这是我写的调用数据库的程序在这一句rs!合格判断 = Text2.Text提示类型不匹配
请各位大侠 帮忙看看怎么修改
[解决办法]
Dim conn As New ADODB.ConnectionDim rs As New ADODB.RecordsetDim Str1 As StringDim Str2 As StringDim Str3 As StringDim strSQL As String'Dim 合格判断 As Long'Dim 采集日期 As Date'Dim 采集时间 As StringStr1 = "Provider=Microsoft.Jet.OLEDB.4.0;"Str2 = "Data Source=E:\temp1.mdb;"Str3 = "Jet OLEDB:Database Password="conn.Open Str1 & Str2 & Str3if trim(text2.text)="" then msgbox "请输入合格判断!",48,"提示" exit subelse if not isnumeric(text2.text) then msgbox "请输入数值型数据!",48,"提示" text2.setfocus exit sub end ifend ifif trim(text3.text)="" then msgbox "请输入采集日期!",48,"提示" exit subelse if not isdate(text3.text) then msgbox "请输入日期型数据!",48,"提示" text3.setfocus end ifend ifconn.execute "insert into tb(合格判断,采集日期,采集时间) values("& text2.text &",#"& text3.text &"#,'"& text4.text &"')"conn.Close
[解决办法]
看出错时 text2的值
可以加val
[解决办法]
rs!合格判断 = Text2.Text提示类型不匹配
注意以下几点:
“合格判断” 类型为long,则最好转换Text2.Text
需要判断Text2.Text不为空的情况。
判断Text2.Text不为空,且需要转换成功!
rs!合格判断 = CLNG(Text2.Text)