求一个简单的查询代码 如上图所示,一个datetimepicker,然后从数据库中查询出对应的值显示到下面的控件上就可以SQL=select content from table where datediff(dd,'" + datetimepicker.Value.ToString() + "',worktime)=0急求,希望大家能帮个忙! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 string sql="select content from table where datediff(dd,'" + datetimepicker.Value.ToString("yyyy-MM-dd") + "',worktime)=0";绑定到datagridviewusng(SqlConnetion conn=new SqlConnetions("")){} 什么控件都可以,显示新闻内容的,能容纳多点的就可以,只读一条数据的一个字段的没写过winform程序,不清楚怎么搞 datagridviewlistview都可以 private void button1_Click(object sender, EventArgs e) { try { OleDbConnection conn = ConnClass.DataConn(); conn.Open(); string str = "select * from table where datediff(dd,'" + Writertime.Value.ToString() + "',Writertime)=0"; oledcmd = new OleDbCommand(str, conn); oleRed = oledcmd.ExecuteReader(); MessageBox.Show(oleRed["content"].ToString()); while (oleRed.Read()) { content.Text = oleRed["content"].ToString(); } oleRed.Close(); } catch (Exception ee) { MessageBox.Show("您查询的日期没找到对应的值!"); } }乱写了个,值传不会去,直接弹出来MessageBox SqlDataAdapter da = new SqlDataAdapter("select content from table where datediff(dd,'" + datetimepicker.Value.ToString() + "',worktime)=0", conn); DataSet ds = new DataSet(); da.Fill(ds); //GridView数据绑定 控件.DataSource = ds; GridView1.DataBind();原理是一样的 winform 用dataGridView控件吧! 后台代码在page_load事件里this.tb_BookInfoTableAdapter.Fill(this.database_bookDataSet.Tb_BookInfo); string conn = "server=.;database=Database_book;uid=sa;pwd=sa;"; using (SqlConnection myCon = new SqlConnection(conn)) { SqlDataAdapter myDa = new SqlDataAdapter("select * from Tb_MemberInfo", myCon); DataSet myDs = new DataSet(); myDa.Fill(myDs, "temTable"); this.dataGridView1.DataSource = myDs.Tables[0];//数据源 }有什么不懂的可以去http://hi.baidu.com/342268154/blog/item/33f9a7da598b44e439012f86.html C# 设置默认网关为空 有人做过串口的误码率测试没有,帮忙指点下或者给个参考神马的 Excel问题(有图) 为什么优秀的.NET程序运行很流畅,一点也不慢呢? 大家好。有没有人知道。如何让winform窗体中的控件自动换行?而不是出现滚动条? 特急问题,高手来啊!!!如何判断一个IP地址属于哪个地区? 随机数不起作用…… c# excel--access C#操作excel的api文档谁有? 还有。 调用组件? 输入字符串的格式不正确 如何在代码编辑区添加文字
usng(SqlConnetion conn=new SqlConnetions(""))
{}
没写过winform程序,不清楚怎么搞
listview
都可以
private void button1_Click(object sender, EventArgs e)
{ try
{ OleDbConnection conn = ConnClass.DataConn();
conn.Open();
string str = "select * from table where datediff(dd,'" + Writertime.Value.ToString() + "',Writertime)=0";
oledcmd = new OleDbCommand(str, conn); oleRed = oledcmd.ExecuteReader(); MessageBox.Show(oleRed["content"].ToString());
while (oleRed.Read())
{
content.Text = oleRed["content"].ToString();
}
oleRed.Close(); }
catch (Exception ee)
{
MessageBox.Show("您查询的日期没找到对应的值!"); }
}
乱写了个,值传不会去,直接弹出来MessageBox
", conn);
DataSet ds = new DataSet();
da.Fill(ds); //GridView数据绑定
控件.DataSource = ds;
GridView1.DataBind();
原理是一样的
后台代码在page_load事件里
this.tb_BookInfoTableAdapter.Fill(this.database_bookDataSet.Tb_BookInfo);
string conn = "server=.;database=Database_book;uid=sa;pwd=sa;";
using (SqlConnection myCon = new SqlConnection(conn))
{
SqlDataAdapter myDa = new SqlDataAdapter("select * from Tb_MemberInfo", myCon);
DataSet myDs = new DataSet();
myDa.Fill(myDs, "temTable");
this.dataGridView1.DataSource = myDs.Tables[0];//数据源
}
有什么不懂的可以去http://hi.baidu.com/342268154/blog/item/33f9a7da598b44e439012f86.html