读书人

sda.SelectCommand.Connection = con

发布时间: 2012-04-07 17:31:50 作者: rapoo

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();
……

读书人网 >asp.net

热点推荐