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 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提示类型不匹配
请各位大侠 帮忙看看怎么修改
解决方案 »
- vb连接sql2005数据库时候错误-2147467259 (80004005)
- 我的VB引用部件里看不到microsoft word x.0 object library ?
- 怎样将.EXE文件用VB再打开
- 问树形结构模型数据库的设计问题?要求提取数据时效率高,而且数据库的结构在各种大型数据库通用,维护方便!
- 如何实现拨号(在线等待)
- 一个类有两百多个属性,现在想用一个算法把所有的属性名称打印出来,要怎么做?
- 有问题!
- 关于CommandButton 控件
- 如何把数据库打开的语句封装到 .dll文件中去呀?
- 系统托盘区问题!
- 如何用sql语句创建带日期字段的access表
- SQL语句转为VB字符串
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 & Str3if trim(text2.text)="" then
msgbox "请输入合格判断!",48,"提示"
exit sub
else
if not isnumeric(text2.text) then
msgbox "请输入数值型数据!",48,"提示"
text2.setfocus
exit sub
end if
end ifif trim(text3.text)="" then
msgbox "请输入采集日期!",48,"提示"
exit sub
else
if not isdate(text3.text) then
msgbox "请输入日期型数据!",48,"提示"
text3.setfocus
end if
end ifconn.execute "insert into tb(合格判断,采集日期,采集时间) values("& text2.text &",#"& text3.text &"#,'"& text4.text &"')"
conn.Close
我想通过ADO控件写到 我已经做好的ACCESS表格中 这样怎么弄哈?
Private Sub MSComm1_OnComm()
Select Case MSComm1.CommEvent
Case comEvReceive '接收到数据Dim BytReceived() As Byte
Dim strBuff As Variant
Dim strData As String
Dim i As Integer
strBuff = MSComm1.Input '读入到缓冲区
If MSComm1.InputMode = comInputModeBinary Then
BytReceived() = strBuff '如果是二进制接收模式则进行数据处理,否则直接显示字符串
For i = 0 To UBound(BytReceived)
If Len(Hex(BytReceived(i))) = 1 Then
strData = strData & "0" & Hex(BytReceived(i)) & " " '如果只有一个字符,则前补0,如F显示0F,最后补空格
Else '方便显示观察如: 00 0F FE
strData = vbCrLf & strData & Hex(BytReceived(i)) & "^"
End If
Next
Text2 = Text2 & strData
strData = ""
Else
Text2 = Text2 & strBuff
End If
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
采集日期 日期/时间
采集时间 日期/时间
Dim 合格判断 As Long
Dim 采集日期 As Date
Dim 采集时间 As String
这是我在程序里的设置
********88^01 02 03 00 02 22^33^44^55^66^77^88^
把这些数据都存放在 text2里面 ,这些数据里开头的88是扩展帧的帧信息 01 02 03 00是标识符
01 22^33^44^55^66^77^88^ 是接收到的数据8个字节 这里面就是计数没有其它信息
text3存放系统日期
text4存放系统时间
********88^01 02 03 00 02 22^33^44^55^66^77^88^
把这些数据都存放在 text2里面 ,这些数据里开头的88是扩展帧的帧信息 01 02 03 00是标识符
01 22^33^44^55^66^77^88^ 是接收到的数据8个字节 这里面就是计数没有其它信息
这些数据都是16进制的数据 因为我的传输总线要求必须用16进制的数据
注意以下几点:
“合格判断” 类型为long,则最好转换Text2.Text
需要判断Text2.Text不为空的情况。判断Text2.Text不为空,且需要转换成功!
rs!合格判断 = CLNG(Text2.Text)