我自己写的是这样的 点击登陆按钮
SqlConnection con = new SqlConnection("server=(local);database=xzgw;uid:sa;pwd:123;");
con.Open();
string sqlStr = "select count(*) from [user] where username='" + TextBox1.Text + "'and password='" + TextBox2.Text + "'";
SqlCommand com = new SqlCommand(sqlStr, con);
int result = (int)com.ExecuteScalar();
if (result > 0)
Response.Redirect("Default.aspx");
else
Response.Write("<script>alert('用户名或密码错误!')</script>");
con.Close();
[ArgumentException: 从索引 29 处开始,初始化字符串的格式不符合规范。]
System.Data.Common.DbConnectionOptions.GetKeyValuePair(String connectionString, Int32 currentPosition, StringBuilder buffer, Boolean useOdbcRules, String& keyname, String& keyvalue) +1242
System.Data.Common.DbConnectionOptions.ParseInternal(Hashtable parsetable, String connectionString, Boolean buildChain, Hashtable synonyms, Boolean firstKey) +126
System.Data.Common.DbConnectionOptions..ctor(String connectionString, Hashtable synonyms, Boolean useOdbcRules) +102
System.Data.SqlClient.SqlConnectionString..ctor(String connectionString) +52
System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous) +24
System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(String connectionString, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions) +125
System.Data.SqlClient.SqlConnection.ConnectionString_Set(String value) +56
System.Data.SqlClient.SqlConnection.set_ConnectionString(String value) +4
System.Data.SqlClient.SqlConnection..ctor(String connectionString) +21
login.ImageButton1_Click(Object sender, ImageClickEventArgs e) +30
System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e) +86
System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument) +115
System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746
我也不会调试 根本不懂啊!在做购物网站的用户登陆页面~
------解决方案--------------------------------------------------------
try
SqlConnection con = new SqlConnection("server=.;database=xzgw;uid=sa;pwd=123;");
------解决方案--------------------------------------------------------
SqlConnection con = new SqlConnection("server=(local);database=xzgw;uid=sa;pwd=123");
中间是等于,不是冒号
------解决方案--------------------------------------------------------
uid=sa;pwd=123
------解决方案--------------------------------------------------------