private void dateTimePicker3_CloseUp(object sender, System.EventArgs e)
{ try
{ string tempSQL="select * from 入库单 where convert(DateTime, 入库日期 ) between '"+this.dateTimePicker2.Text.ToString().Trim()+"' and '"+this.dateTimePicker3.Text.ToString().Trim()+"'";
this.ds=link.SelectDataBase(tempSQL,sendTableName);
if(ds.Tables[0].Rows.Count!=0)
{
this.dgrd_IN.DataSource=this.ds.Tables[0];
}
else
{
MessageBox.Show("没有记录!");
this.dateTimePicker2.Text=System.DateTime.Today.ToShortDateString();
this.dateTimePicker3.Text=System.DateTime.Today.ToShortDateString();
dgrdRef();
return;
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
} }提示说“从string 转换成datetime类型出现语法错误”;
建的表中”入库日期”是(char)型,我换成datetime型也不行啊。这是错在什么地方啦?昨天几们朋友给的方法我也试了,也不行,请各位再帮帮!~~
{ try
{ string tempSQL="select * from 入库单 where convert(DateTime, 入库日期 ) between '"+this.dateTimePicker2.Text.ToString().Trim()+"' and '"+this.dateTimePicker3.Text.ToString().Trim()+"'";
this.ds=link.SelectDataBase(tempSQL,sendTableName);
if(ds.Tables[0].Rows.Count!=0)
{
this.dgrd_IN.DataSource=this.ds.Tables[0];
}
else
{
MessageBox.Show("没有记录!");
this.dateTimePicker2.Text=System.DateTime.Today.ToShortDateString();
this.dateTimePicker3.Text=System.DateTime.Today.ToShortDateString();
dgrdRef();
return;
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
} }提示说“从string 转换成datetime类型出现语法错误”;
建的表中”入库日期”是(char)型,我换成datetime型也不行啊。这是错在什么地方啦?昨天几们朋友给的方法我也试了,也不行,请各位再帮帮!~~
解决方案 »
- .net Remoting 的问题
- 老人帮我看看这几本c#那个好
- 如何获得资源管理器中文件的完整路径?
- 初学XML,怎么把这个XML文件循环写入数据库啊,高分请教!!!!!!!!!!!
- 那位帅哥帮忙把这段JS MD5加密的脚本 写成C#的
- 怎样保证一个固定的帧频?
- 学C#是先学基础,还是直接做东西,困惑中~~
- 急!!!数据库中的image字段在RichTextBox中如何显示?
- 如何在2005下用c#开发ug 摸板那里可以下到
- to wd_318(初学者.net),winform,DataGrid中的数据无效时,怎样设置焦点不让离开?
- 批号的改变的问题。
- copall(民工->>席卷天下-包举宇内-囊括四海-并吞八荒!)、Knight94(愚翁)请帮忙
改为
this.dateTimePicker2.Value.ToString()
SqlDataAdapter myDBAdapter = new SqlDataAdapter( strQuery, yourConn );
myDBAdapter.SelectCommand.Parameters.Add( "@StartDate", yourStartDate );
myDBAdapter.SelectCommand.Parameters.Add( "@EndDate", yourEndDate );
DataSet ds = new DataSet();
myDBAdapter.Fill( ds, "库存表" );//You can do some operation with ds
//Caution: dispose "myDBAdapter" after use
myDBAdapter.SelectCommand.Parameters.Add( "@StartDate", dateTimePicker3.Value);