你好,请问,我想用1个按钮通过select语句查询odbc 中dsn="WDR" 的数据库 中的表'DE'的列名为'标准时间'中 时间=' '(用vb中的文本框输入的时间) 。使用form1\adodc1\ datagrid1\ text1\command1 当按下 command1 时 datagrid1 就会列出标准时间这列的中时间为 text1 中的时间的所有 的记录行。指针指向 第1条 符合条件的记录。当无记录时 会msgbox"找不到!" 。请 大哥帮忙,很急 谢谢拨冗答复。
我的信箱是[email protected]
我的信箱是[email protected]
解决方案 »
- 如何用ole打开指定的powerpoint
- 做过考勤的来说说,该用哪种考勤算法,提些建议!(100分跪求!!!)
- 把一个工程生成exe文件以后,里面的datagrid上显示不出来数据了,请教大家了,这是为何?
- 求:将数据从Excel导入Access数据库
- 算法问题,谁听说过这种算法?高分求解
- 日期相减问题!
- 关于Listview控件和Imagelist控件关联显示图标的问题?
- activex问题
- 请问如何在datareport中显示程序中的变量
- 帮小弟一把:vb到底学什么?(我给全分!!!)
- mshflexgrid + Text 问题 急急急
- 紧急求购一个VB的控件!!!必有重谢!!毕业设计!
'“工程”->“引用”,选中“Microsoft ActiveX Data Objects 2.* Library”
Dim GCon As New ADODB.ConnectionPrivate Sub Command1_Click()
Dim rsTest As New ADODB.Recordset
Dim strSQL As String
If Not IsDate(Text1.Text) Then
MsgBox "请输入正确格式的日期!", vbInformation, "提示"
Exit Sub
End If
strSQL = "select * from DE where 标准时间=#" & Format(Text1.Text, "yyyy-MM-dd hh:mm:ss") & "#"
rsTest.Open strSQL, GCon, adOpenStatic, adLockOptimistic
If rsTest.RecordCount < 0 Then
MsgBox "没有找到匹配记录!", vbInformation, "提示"
Else
Set DataGrid1.DataSource = rsTest
End If
End SubPrivate Sub Form_Load()
GCon.CursorLocation = adUseClient
GCon.Open "DSN=WDR;UID=;PWD="
End Sub
Dim strSQL As String
strSQL = "select * from DE where 标准时间=Text1.text" '''这里有误 怎么改呢,变量的问题 格式不对。。??
rsTest.Open strSQL, GCon, adOpenStatic, adLockOptimistic
If rsTest.RecordCount < 0 Then
MsgBox "没有找到匹配记录!", vbInformation, "提示"
Else
Set DataGrid1.DataSource = rsTest
End If
strSQL = "select * from DE where 标准时间=Text1.text"
应为:
strSQL = "select * from DE where 标准时间='" & Text1.text & "'" '(SQL Server中)
或
strSQL = "select * from DE where 标准时间=#" & Text1.text & "#" '(Access中)
strSQL = "select * from DE where 标准时间='8.5'" 则datagrid得出 所有的 符合的记录