日期:2014-05-17  浏览次数:20529 次

“string”并不包含“conn”的定义
string strConnection = @"Data Source=.;Initial Catalog=new1;Integrated Security=True";
  SqlConnection conn = new SqlConnection(strConnection);
  conn.Open();
  string strsql = "selcet * from [baoxiu] where [name]='session[userName]' and mon>='"+startime.Text+"' and mon<='"+overtime.Text+"'";
  SqlDataAdapter cmd = new SqlDataAdapter(strsql.conn);
  DataSet dataset =new DataSet();
  cmd.Fill(dataset);
  GridView2.DataSource = dataset;
  GridView2.DataBind();
  conn.Close();
应该没有问题吧?为什么会报错?

------解决方案--------------------
SqlDataAdapter cmd = new SqlDataAdapter(strsql.conn); //这里不是.应该是下面的
SqlDataAdapter cmd = new SqlDataAdapter(strsql,conn);
------解决方案--------------------
SqlDataAdapter cmd = new SqlDataAdapter(strsql.conn);

==>>

SqlDataAdapter cmd = new SqlDataAdapter(strsql, conn);
------解决方案--------------------
看看介个呗
------解决方案--------------------
我艹,你把逗号写成点号了!

太粗心了!
------解决方案--------------------
SqlDataAdapter cmd = new SqlDataAdapter(strsql.conn);

语句和conn对象中间要用“,”隔开
我想你题目也写错了要写:
“strsql”并不包含“conn”的定义