代码如下,完全看不出什么错误,但就是提示:“;”附近有语法错误!!(如下)
谁要看得出是什么错误那真神了!~stringtempname;stringtemppassword;//tempname=TextBox1.Text;//temppass...
谁要看得出是什么错误那真神了!~
string tempname;
string temppassword;
// tempname = TextBox1.Text ;
// temppassword = TextBox2.Text;
//SqlConnection objConnection = new SqlConnection();
SqlConnection objConnection = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename='C:\\Documents and Settings\\Administrator\\My Documents\\Visual Studio 2010\\WebSites\\WebSiteDateBaseProject\\App_Data\\Database1.mdf';Integrated Security=True;User Instance=True");
objConnection.Open();
SqlCommand strCommand = objConnection.CreateCommand();
strCommand.CommandText = "Insert Into [User](name,password); values(@tempname,@temppassword)";
// com.CommandText = "Insert into T_students(name, age) values(@name, 18)";
strCommand.Parameters.Add(new SqlParameter(@"tempname", TextBox1.Text));
strCommand.Parameters.Add(new SqlParameter(@"temppassword", TextBox2.Text));
// com.ExecuteNonQuery();
strCommand.Connection = objConnection;
strCommand.ExecuteNonQuery();
Response.Write("恭喜你注册成功~");
objConnection.Close();
网页显示结果
异常详细信息: System.Data.SqlClient.SqlException: ';' 附近有语法错误。
源错误:
行 33: // com.ExecuteNonQuery();
行 34: strCommand.Connection = objConnection;
行 35: strCommand.ExecuteNonQuery();
行 36: Response.Write("恭喜你注册成功~");
行 37: objConnection.Close(); 展开
string tempname;
string temppassword;
// tempname = TextBox1.Text ;
// temppassword = TextBox2.Text;
//SqlConnection objConnection = new SqlConnection();
SqlConnection objConnection = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename='C:\\Documents and Settings\\Administrator\\My Documents\\Visual Studio 2010\\WebSites\\WebSiteDateBaseProject\\App_Data\\Database1.mdf';Integrated Security=True;User Instance=True");
objConnection.Open();
SqlCommand strCommand = objConnection.CreateCommand();
strCommand.CommandText = "Insert Into [User](name,password); values(@tempname,@temppassword)";
// com.CommandText = "Insert into T_students(name, age) values(@name, 18)";
strCommand.Parameters.Add(new SqlParameter(@"tempname", TextBox1.Text));
strCommand.Parameters.Add(new SqlParameter(@"temppassword", TextBox2.Text));
// com.ExecuteNonQuery();
strCommand.Connection = objConnection;
strCommand.ExecuteNonQuery();
Response.Write("恭喜你注册成功~");
objConnection.Close();
网页显示结果
异常详细信息: System.Data.SqlClient.SqlException: ';' 附近有语法错误。
源错误:
行 33: // com.ExecuteNonQuery();
行 34: strCommand.Connection = objConnection;
行 35: strCommand.ExecuteNonQuery();
行 36: Response.Write("恭喜你注册成功~");
行 37: objConnection.Close(); 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询