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

求教解决方法

2012-03-16 
求教con.Open()SqlCommandcmd1newSqlCommand( select*fromfie_VoteList ,con)SqlDataReadersadcmd1.

求教
con.Open();
                SqlCommand   cmd1   =   new   SqlCommand( "select   *   from   fie_VoteList ",   con);
                SqlDataReader   sad   =   cmd1.ExecuteReader();
                this.RadioButtonListVoteList.DataSource   =   sad;
                this.RadioButtonListVoteList.DataValueField   =   "VLid ";
                this.RadioButtonListVoteList.DataTextField   =   "VoteList ";
                this.RadioButtonListVoteList.DataBind();
                sad.Close();
                con.Close();

有错吗?
怎么什么都显示不出来

[解决办法]
把SqlDataReader sad = cmd1.ExecuteReader();
换成DataSet sad = cmd1.ExecuteDataSet();
[解决办法]
con.Open();
SqlCommand cmd1 = new SqlCommand( "select * from fie_VoteList ", con);
SqlDataReader sad = cmd1.ExecuteReader();
if(sad.Read())
{
this.RadioButtonListVoteList.DataSource = sad;
this.RadioButtonListVoteList.DataValueField = "VLid ";
this.RadioButtonListVoteList.DataTextField = "VoteList ";
this.RadioButtonListVoteList.DataBind();
}
sad.Close();
con.Close();

因为 DataReader 是只读向前的```

楼上的也是对的

热点排行