Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

SQL查询,数据类型不匹配的问题

1 view
Skip to first unread message

Cookie

unread,
Feb 2, 2005, 11:27:17 PM2/2/05
to
我在一个网页中需要做一个查询,
查找某一天(p_date),时间(p_time)晚于某个时刻,并且早于另一个时刻的所有记录。

数据库我是第一次使用Access
数据库模式:pair(p_id,p_name,p_date,p_time)
p_date格式:yyyy-MM-dd
p_time格式:hh:mm

这样的一个sql语句怎么写呢?
我的SQL语句在Access成功完成了查询,
可是为什么在程序中却出现了数据类型不匹配呢?
谢谢

--
Cookie Ren
School of Computer Engineering and Science,
Shanghai University.
-------------------------------------------------
Everything is good when new, but friends when old.
http://cookieren.blogchina.com/


小李菜刀

unread,
Feb 3, 2005, 2:35:19 AM2/3/05
to
您好,Cookie:
那说明你的程序有问题啦,把你的代码贴出来让大家看看。
在 2005-2-3 12:27:17 的来信中您写到:

--
小李菜刀 <caid...@hotmail.com>

Cookie

unread,
Feb 3, 2005, 4:41:56 AM2/3/05
to
tedb.sb.Append("select user_name,p_date,p_time from [pair],[user] where
p_user_id=user_id and p_from_station={0} and p_to_station={1} and
p_date='{2}' and p_time>='{3}' and p_time<='{4}'");

tedb.values.Add(N2I.getID2("station","station_id","station_line",ddlSL1.SelectedItem.ToString(),"station_name",ddlSS1.SelectedItem.ToString()));
tedb.values.Add(N2I.getID2("station","station_id","station_line",ddlDL1.SelectedItem.ToString(),"station_name",ddlDS1.SelectedItem.ToString()));
tedb.values.Add(Convert.ToDateTime(txtDate1.Text).ToShortDateString());
tedb.values.Add(Convert.ToDateTime(txtTime1.Text).ToShortTimeString());
tedb.values.Add(Convert.ToDateTime(txtTime2.Text).ToShortTimeString());

tedb.sql=String.Format(tedb.sb.ToString(),tedb.values.ToArray());
tedb.adapter=new System.Data.OleDb.OleDbDataAdapter(tedb.sql,tedb.con);

tedb.adapter.Fill(tedb.ds);
dgSearch.DataSource=tedb.ds.Tables[0];
dgSearch.DataBind();

--
Cookie Ren
School of Computer Engineering and Science,
Shanghai University.
-------------------------------------------------
Everything is good when new, but friends when old.
http://cookieren.blogchina.com/

"小李菜刀" <caid...@hotmail.com> 写入消息新闻:20050203153456...@hotmail.com...

Cookie

unread,
Feb 4, 2005, 7:22:56 AM2/4/05
to
我在一个网页中需要做一个查询,
查找某一天(p_date),时间(p_time)晚于某个时刻,并且早于另一个时刻的所有记录。


数据库我是第一次使用Access
数据库模式:pair(p_id,p_name,p_date,p_time)
p_date格式:yyyy-MM-dd
p_time格式:hh:mm

这样的一个sql语句怎么写呢?
我的SQL语句在Access成功完成了查询,
可是为什么在程序中却出现了数据类型不匹配呢?
谢谢
源程序:

0 new messages