dim sql as string sql="select * from 表 where 日期=#" & MonthView1.Value & "#"
Me.MonthView1.Value这个是时间先得到时间,比如 dim strDate as Date strDate=Me.MonthView1.Value然后再去写SQL语句去查找 select * from TableName where DateTime=#" strDate "# '记主access中间是用#去查时间查出的记录读进报表这个不用说了吧。另外。给你两点看法 1、dbgrid已经是vb5的东西,再怎么也换成datagrid吧,完全可以抛弃了 2、你使用DTPicker可能更符合你的要求,而不是使用MonthView
我用以下语法,结果在DBGrid中没有任何记录显示,而我的ACCESS数据中明明有相应的日期。帮我看看那里错了: Private Sub Command1_Click() Dim strDate As Date strDate = Me.MonthView1.Value Text1.Text = strDate Adodc1.RecordSource = "select * from 表1 where date=" + Text1.Text Adodc1.Refresh End Sub
"select * from 表1 where date=" & "'" & Text1.Text & "'"
"select * from 表1 where date=" & "'" & Text1.Text & "'" 换成以上SQL语句后,执行command1报错如下: [Microsoft][odbc microsoft access驱动程序]标准表达表中数据类型不匹配 我用的ACCESS数据,date这个字段用的是“日期/时间”.为什么会有以上的错误呢?
我已经讲过了时间形态为#在access中间,你咱的灭看呢?????
再次重复我上面的话:然后再去写SQL语句去查找 select * from TableName where DateTime=#" strDate "# '记主access中间是用#去查时间看见我后面的注释没,没药了。
MonthView1.Value可以连接到SQL字符串的,会自动转化为日期字符串
楼上的楼上的这位大哥,8对吧? select * from TableName where DateTime=#" strDate "# 素虾米意思?应该是这样的吧: "select * from TableName where DateTime=#" & strDate & "#"
sql="select * from 表 where 日期=#" & MonthView1.Value & "#"
dim strDate as Date
strDate=Me.MonthView1.Value然后再去写SQL语句去查找
select * from TableName where DateTime=#" strDate "# '记主access中间是用#去查时间查出的记录读进报表这个不用说了吧。另外。给你两点看法
1、dbgrid已经是vb5的东西,再怎么也换成datagrid吧,完全可以抛弃了
2、你使用DTPicker可能更符合你的要求,而不是使用MonthView
比如说FORM1现有控件:MonthView1,Command1, BGrid1,Adodc1通过DNS正常连接到文件db1.ldb(ACCESS),数据源为“表1”
其功能就是要通过选中MonthView1某一日(如2005-5-12),再单击command1,让BGrid1中显示“表1”中所有符合条件的记录呢?能否给出源码让我学习一下。
Adodc1.Refresh不知道是不是这样,没有去试验。
其功能就是要通过选中MonthView1某一日(如2005-5-12),再单击command1,让BGrid1中显示“表1”中所有符合条件(2005-5-12)的记录呢?能否给出源码让我学习一下。
真诚求教
Private Sub Command1_Click()
Dim strDate As Date
strDate = Me.MonthView1.Value
Text1.Text = strDate
Adodc1.RecordSource = "select * from 表1 where date=" + Text1.Text
Adodc1.Refresh
End Sub
换成以上SQL语句后,执行command1报错如下:
[Microsoft][odbc microsoft access驱动程序]标准表达表中数据类型不匹配
我用的ACCESS数据,date这个字段用的是“日期/时间”.为什么会有以上的错误呢?
select * from TableName where DateTime=#" strDate "# '记主access中间是用#去查时间看见我后面的注释没,没药了。
select * from TableName where DateTime=#" strDate "#
素虾米意思?应该是这样的吧:
"select * from TableName where DateTime=#" & strDate & "#"