当前位置:编程学习 > C#/ASP.NET >>

连接数据库时的问题...

    public SqlDataReader Reader()
    {
        SqlConnection MyConnection = new SqlConnection("server=F087589640C345A\\SQLEXPRESS;user=sa;pwd=accp;database=MyBookShop");

        MyConnection.Open();
        string message = string.Format("select * from {0}",this.TextBox1);
        SqlCommand MyCommand = new SqlCommand(null, MyConnection);
        MyCommand.CommandText = message;
        SqlDataReader MyDataReader = MyCommand.ExecuteReader();
        return MyDataReader;
    }
[img=C:\Documents and Settings\Administrator.F087589640C345A\桌面][/img] --------------------编程问答-------------------- 图?  ?? --------------------编程问答-------------------- 对象 名称 'System.Web.UI.WebControls.TextBox' 包含的前缀超出了最大限值。最多只能有 3 个

这个错 --------------------编程问答-------------------- this.TextBox1.Text --------------------编程问答-------------------- this.TextBox1.Text 才是文本框里面的内容... --------------------编程问答-------------------- LZ 5个帖子都没结啊 --------------------编程问答-------------------- 怎么结贴告分不够呢.... .. --------------------编程问答-------------------- this.TextBox1.Text 才是文本框里面的内容... --------------------编程问答-------------------- suing(SqlConnection MyConnection = new SqlConnection(""))
{

  MyConnection.Open();
  string message = string.Format("select * from {0}",this.TextBox1.Text);
}
--------------------编程问答-------------------- using(SqlConnection MyConnection = new SqlConnection(""))
{

  MyConnection.Open();
  string message = string.Format("select * from {0}",this.TextBox1.Text);
}
--------------------编程问答-------------------- using(SqlConnection MyConnection = new SqlConnection(""))
{

  MyConnection.Open();
  string message = string.Format("select * from {0}",this.TextBox1.Text);
}
 
 
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,