主题:菜鸟请教个问题!各位帮帮忙啊!
我之前学过ASP.现在想学ASP.net..不过第一天就碰到了问题!想拿个例子来看看..没想到一搞就是一天!怎么也做不好!大家帮帮忙啊!
是这样的:运行时的错误是:
System.ArgumentException: 不支持关键字: “persist security inof”。
源错误:
行 16: string cmdtxt1 = "Persist Security Inof=false;Integrated Security=SSPI;sever=(local);database=tiyie;user id=sa;Pwb=";
行 17: string cmdtxt2 = "select shuname,email,phone1,ding from orders";
行 18: SqlConnection Con = new SqlConnection(cmdtxt1);
行 19: Con.Open();
行 20: SqlDataAdapter da = new SqlDataAdapter(cmdtxt2, Con);
我的代码是:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string cmdtxt1 = "Persist Security Inof=false;Integrated Security=SSPI;sever=(local);database=tiyie;user id=sa;Pwb=";
string cmdtxt2 = "select shuname,email,phone1,ding from orders";
SqlConnection Con = new SqlConnection(cmdtxt1);
Con.Open();
SqlDataAdapter da = new SqlDataAdapter(cmdtxt2, Con);
DataSet ds = new DataSet();
da.Fill(ds);
this.Gridview1.DataSource = ds;
this.Gridview1.DataBind();
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
this.Gridview1.PageIndex = e.NewPageIndex;
this.Gridview1.DataBind();
}
}
是这样的:运行时的错误是:
System.ArgumentException: 不支持关键字: “persist security inof”。
源错误:
行 16: string cmdtxt1 = "Persist Security Inof=false;Integrated Security=SSPI;sever=(local);database=tiyie;user id=sa;Pwb=";
行 17: string cmdtxt2 = "select shuname,email,phone1,ding from orders";
行 18: SqlConnection Con = new SqlConnection(cmdtxt1);
行 19: Con.Open();
行 20: SqlDataAdapter da = new SqlDataAdapter(cmdtxt2, Con);
我的代码是:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string cmdtxt1 = "Persist Security Inof=false;Integrated Security=SSPI;sever=(local);database=tiyie;user id=sa;Pwb=";
string cmdtxt2 = "select shuname,email,phone1,ding from orders";
SqlConnection Con = new SqlConnection(cmdtxt1);
Con.Open();
SqlDataAdapter da = new SqlDataAdapter(cmdtxt2, Con);
DataSet ds = new DataSet();
da.Fill(ds);
this.Gridview1.DataSource = ds;
this.Gridview1.DataBind();
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
this.Gridview1.PageIndex = e.NewPageIndex;
this.Gridview1.DataBind();
}
}