我是编程的新手.我有我的程序有问题,我所要做的是创建一个注册页面,以便用户可以注册,它会保存到SQL数据库,但我得到了一个错误,我不知道这意味着什么,我会全贴错误消息抱歉,如果它不具体.如果可能的话,请用简单的语言向我解释.
这是我的代码:
protected void registerBtn_Click(object sender, EventArgs e)
{
String conString = @"Data Source=sql-server;Initial Catalog=wa310;Integrated Security=True";
SqlConnection myConnection = new SqlConnection(conString);
string cmd = "INSERT INTO Student( First_Name, Surname, User_ID, Password) VALUES ( '" + fNameTxt.Text + "' , '" + sNameTxt.Text + "','" + userIdTxt.Text + "' ,'" + passwordTxt.Text + "')";
SqlCommand myCommand = new SqlCommand(cmd, myConnection);
try
{
myCommand.Connection = myConnection;
myConnection.Open();
myCommand.ExecuteNonQuery();
Label1.Text = "You have successfully registered";
}
catch (Exception ex)
{
Label1.Text = "Exception …Run Code Online (Sandbox Code Playgroud)