首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

sda.SelectCommand.Connection = con 提示 未将对象引用设置到对象的实例,该如何处理

2012-04-07 
sda.SelectCommand.Connection con 提示 未将对象引用设置到对象的实例提示 未将对象引用设置到对象的实

sda.SelectCommand.Connection = con 提示 未将对象引用设置到对象的实例
提示 未将对象引用设置到对象的实例。 sda.SelectCommand.Connection = con;错误,一下是源代,怎么解决
  sda.SelectCommand.Connection = con;

C# code
            SqlConnection con = Ares.WebSite.App_Code.DB.CreateConn();            con.Open();            SqlDataAdapter sda = new SqlDataAdapter();            sda.SelectCommand.Connection = con;            sda.SelectCommand.CommandText = "select * from M_SalesTab";            DataSet ds = new DataSet();            sda.Fill(ds);            Response.Write(ds.Tables[0].Rows[0][1].ToString());


[解决办法]
引用
SqlDataAdapter sda = new SqlDataAdapter();
sda.SelectCommand.Connection = con;
sda.SelectCommand.CommandText = "select * from M_SalesTab";

[解决办法]
探讨

引用
SqlDataAdapter sda = new SqlDataAdapter();
sda.SelectCommand.Connection = con;
sda.SelectCommand.CommandText = "select * from M_SalesTab";

我怎么感觉这里少了一步 sda.SelectCommand = new SqlCommand();
……

热点排行