请教一段代码 此处SqlDataAdapter ada = new SqlDataAdapter(SqlStr, con); 设置断点,单步调试一下看SqlStr是什么东东,然后在数据库中执行一下,看是不是有数据。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 把sql语句放到数据库里执行…… private void button1_Click(object sender, EventArgs e) { try { string ConStr = "server=(local);user id=sa;pwd=;database=dada_2010"; SqlConnection con = new SqlConnection(ConStr); StringBuilder sb = new StringBuilder(); sb.Append(@"select * from mertrial"); string SqlStr = sb.ToString() + "where Convert(datetime,Convert(varchar(10),DATE,120)) between'" + ((Form1)this.Owner).dateTimePicker1.Value.ToShortDateString() + "'and'" + ((Form1this.Owner).dateTimePicker2.Value.ToShortDateString() + "'"; SqlDataAdapter ada = new SqlDataAdapter(SqlStr, con); DataSet ds = new DataSet(); ada.Fill(ds); this.dataGridView1.DataSource = ds.Tables[0].DefaultView; } catch { return; } } sb.Append(@"select * from ,mertrial"); 这个,号起啥作用滴?? 你的就是button1_Click事件,从数据库里面取出数据填充在GridView里面 public void Button1_Click(object sender, EventArgs e) { string str = @"server=.\SQLEXPRESS;database=db_CSManage;uid=sa;pwd=sa"; SqlConnection Conn = new SqlConnection(str); string sql = "select * from mertrial"; SqlDataAdapter sd = new SqlDataAdapter(sql, Conn); DataSet ds = new DataSet(); sd.Fill(ds); this.dataGridView1.DataSource = ds.Tables[0].DefaultView; }这样呢? 嗯那个逗号 代码里没有的 ,用6楼的那个是可以的 但我想根据这个DATE 字段来查询出相匹配的数据 用我那个代码 就查不出来任何数据 请教下如何弄 谢谢大家 TextBox的OnTextChange事件如何用JS的做啊 powerbuilder的有关问题 Winform:添加报警声音 ASP.NET启动Windows服务 數據的表示形式 跪求.net水晶报表实例!!! C#窗体程序:求将字符串插入textBox光标所在位置的代码 System.Runtime.InteropServices.COMException: 命令失败 void是什么意思? C#中的开方函数是如何? 求助:关于winform中listview控件列标头美化问题 资源绑定的一点问题
{ try
{
string ConStr = "server=(local);user id=sa;pwd=;database=dada_2010"; SqlConnection con = new SqlConnection(ConStr);
StringBuilder sb = new StringBuilder();
sb.Append(@"select * from mertrial");
string SqlStr = sb.ToString() + "where Convert(datetime,Convert(varchar(10),DATE,120)) between'" + ((Form1)this.Owner).dateTimePicker1.Value.ToShortDateString() + "'and'" + ((Form1this.Owner).dateTimePicker2.Value.ToShortDateString() + "'";
SqlDataAdapter ada = new SqlDataAdapter(SqlStr, con);
DataSet ds = new DataSet();
ada.Fill(ds);
this.dataGridView1.DataSource = ds.Tables[0].DefaultView;
}
catch
{
return;
}
}
这个,号起啥作用滴??
public void Button1_Click(object sender, EventArgs e)
{
string str = @"server=.\SQLEXPRESS;database=db_CSManage;uid=sa;pwd=sa";
SqlConnection Conn = new SqlConnection(str);
string sql = "select * from mertrial";
SqlDataAdapter sd = new SqlDataAdapter(sql, Conn);
DataSet ds = new DataSet();
sd.Fill(ds); this.dataGridView1.DataSource = ds.Tables[0].DefaultView;
}
这样呢?
但我想根据这个DATE 字段来查询出相匹配的数据 用我那个代码 就查不出来任何数据 请教下如何弄 谢谢大家