福州海峡培训复读班:rs.open书写

来源:百度文库 编辑:神马品牌网 时间:2024/05/09 08:23:45
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
conn.ConnectionString = "provider=sqloledb.1;persist security info=false;user id=sa;password=;initial catalog=northwind;data source=microsof-0d1123"
conn.Open
rs.CursorLocation = adUseClient
现有一个文本控件(txtorderid,两个DTPicker(分别为dtpfrom dftto)格式属性都为shortdate,查询表为orders.
查询条件:orderid=txtorderid,orderdate(格式为datetime)在dtpfrom和dtpto之间(含起始日期).
问题:在VB中如何书写rs.open语句(包含rs.open的完整语句)
本人花了好多时间还没实现日期格式的转换,谢谢大家指教!
set datagrid1.datasource=rs
谢谢zbywjy!
因orderdate是日期时间格式,所以zbywjy提供的查询结果不包括dtpto.value这天的,可否更改一下?

rs.open "select * from orders where orderid='"& trim(txtorderid.text) &"' and orderdata>'"& dtpfrom.value &"' and orderidata<'"& dftto.value &"'