在线等 急问题 NET 2005高人进

来源:百度知道 编辑:UC知道 时间:2024/07/07 04:28:31
protected void Button1_Click(object sender, EventArgs e)
{
sql sql_select = new sql();
GridView1.DataSource = sql_select.sqlselect(this.TextBox1.Text).Tables[0].DefaultView;
GridView1.DataBind();
}
我点后 GridView1 显示我指定的表 为什么我点了后GridView1什么也不显示啊 我GridView1没有帮定过DATESOURCE
我的方法是
public class sql
{
private string SqlStrirng;
private SqlConnection SqlCont;
private SqlCommand SqlCmd;
private SqlDataAdapter SqlDataAtre;
private DataSet Dst;
private SqlDataReader SqlReder;

public sql()
{
SqlStrirng = ConfigurationManager.ConnectionStrings["sql_2"].ConnectionString;
SqlCmd = new SqlCommand();
SqlCont = new SqlConnection(SqlStrirng);
SqlDataAtre =new SqlDataAdapter();
Dst = new DataSet();
}

public DataSet sqlselect(string sql_name)
{

把你的autogenerateconlumns属性改为FALSE 就行了 楼上的那个.TRIM()你最好加上 因为你TEXT文本框 有时不小心多出点空格什么的就不显示了

没看出来...你试试这个

sql_select.sqlselect(this.TextBox1.Text.Trim()).Tables[this.TextBox1.Text.Trim()].DefaultView

是不是那表里面 没数据啊....在数据库里面写select * from xx能查出来吗?