opcommand.Connection.Open();
你没把 connection 赋值给conmand 你open有啥用SqlDataAdapter myadaddd = new SqlDataAdapter("fwzx", userConnection);
你前面用的 command 没赋值给 DataAdapter
你没把 connection 赋值给conmand 你open有啥用SqlDataAdapter myadaddd = new SqlDataAdapter("fwzx", userConnection);
你前面用的 command 没赋值给 DataAdapter
解决方案 »
- ASP.NET 传参数返回问题
- 保存Excel 时会弹出 隐私问题警告:此文档中包含宏
- 序列化和缓存
- 有个问题请教?
- 求BLOG开发思路
- asp.net页面动态添加多媒体播放器的问题
- 将lable绑定到数据库新闻表,可以显示新闻内容,但是显示的新闻内容没有分段,应该怎么办啊?(急!急!急)
- 前几天无聊做的浏览SQL Server 2000数据库表内容的网页工具。
- 一起讨论一下怎样做无刷新的聊天室?
- 后台跟前台结合来做开发的时候,怎么样才能更好的结合,能够达到在网页上面实现后台的功能?下面有一个实例,大家帮分析一下,谢谢合作!
- 为什么图片会这样
- 菜鸟。刚学Ext。创建按钮之后,点击按钮,怎么调用后台方法?谢谢。
SqlCommand opcommand = new SqlCommand("fwzx", userConnection);
在这里不是赋值吗
改为
SqlDataAdapter myadaddd = new SqlDataAdapter(opcommand);
就可以啊,原因是SqlDataAdapter没有和SqlCommand关联
SqlConnection userConnection = Conn.getConnetion();
SqlDataAdapter myadaddd = new SqlDataAdapter("fwzx", userConnection);
myadaddd.SelectCommand.CommandType=CommandType.StoredProcedure;
SqlParameter fwzx=new Sql....("@fwzx2",SqlDbType.Varchar,50);
fwzx.Value="xxx";
DataSet ds=new DataSet();
myadaddd.SelectCommand.Paramters.Add(fwzx);
myadaddd.Fill(ds);
GridView1.DataSource = ds.Tables[0].DefaultView;
GridView1.DataBind();
SqlCommand opcommand = new SqlCommand("fwzx", userConnection);
opcommand.CommandType = CommandType.StoredProcedure;
opcommand.Parameters.Add("@fwzx2", SqlDbType.VarChar, 50);
opcommand.Parameters["@fwzx2"].Value = DropDownList1.SelectedItem.Text;
opcommand.Connection.Open();
DataSet mydsddd = new DataSet();
mydsddd.Clear();
SqlDataAdapter myadaddd = new SqlDataAdapter();
myadaddd.SelectCommand = opcommand
myadaddd.Fill(mydsddd);
GridView1.DataSource = mydsddd.Tables[0].DefaultView;
GridView1.DataBind();
opcommand.Connection.Dispose();
opcommand.Connection.Close();