cs
------
protected void Page_Load(object sender, EventArgs e)
{
getDate();
}
public void getDate()
{
SqlConnection cn = new SqlConnection("server=localhost;database=BS2.2;user=dili;password=110;");
SqlCommand cmd = new SqlCommand("select * form SS_USER ", cn);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds,"SS_USER"); //调试报错:提示 用户代码未处理 SqlException
this.GridView1.DataSource = ds.Tables[0].DefaultView;
this.DataBind();
}
----------------aspx------
<body>
<div>
<form runat="server" id="form1">
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
</form>
</div>
</body>
------------------错误提示--
第 1 行: 'form' 附近有语法错误。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.Data.SqlClient.SqlException: 第 1 行: 'form' 附近有语法错误。
源错误:
行 24: SqlDataAdapter da = new SqlDataAdapter(cmd);
行 25: DataSet ds = new DataSet();
行 26: da.Fill(ds,"SS_USER"); //提示 用户代码未处理 SqlException
行 27: this.GridView1.DataSource = ds.Tables[0].DefaultView;
行 28: this.DataBind();
源文件: e:\设计\WebSite1\Default.aspx.cs 行: 26
堆栈跟踪:
[SqlException (0x80131904): 第 1 行: 'form' 附近有语法错误。]
参考资料:http://www.biye5u.com/article/netsite/ASPNET/list57-1.html