ArgumentException: 从索引 29 处开始,初始化字符串的格式不符合规范.
我自己写的是这样的 点击登陆按钮
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
我也不会调试 根本不懂啊!在做购物网站的用户登陆页面~
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
我也不会调试 根本不懂啊!在做购物网站的用户登陆页面~
...全文
相关推荐
System.ArgumentException(解决方案).md
项目中碰到的,记录一下
Exception by proxy callSystem.ArgumentException: 已添加项。字典中的关键
NULL 博文链接:https://joe1100.iteye.com/blog/1272940
利用正则表达式巧妙解析度分秒格式字符串
利用正则表达式巧妙解析度分秒格式字符串,代码简单明了同时易于维护。希望和爱好编程的朋友交流
C#超级字符串格式化源码示例
“C#超级字符串格式化源码示例”是本人初学C#时,自己手写的,感觉挺好用的,无论是中文字符,还是英文字符,您只需传入相应的两个参数,就可以达到字符串的格式化。
C#获取字符串后几位数的方法
主要介绍了C#获取字符串后几位数的方法,实例分析了C#操作字符串的技巧,具有一定参考借鉴价值,需要的朋友可以参考下


