网站都能够运行,但未经处理的,当我尝试登录到该网站,我得到这个错误:SQL异常是由用户代码
SQL Exception was unhandled by user code
在这条线=>
catch (SqlException e)
{
throw e;
}
以下是我的登录码DBmanager
:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Collections;
using System.Data.SqlClient;
using System.Configuration;
namespace TopJobAgencyApp.Class
{
public class DBManager
{
public static int InsertLogin(Registration u)
{
int rowsinserted = 0;
SqlConnection conn = null;
try
{
conn = new SqlConnection();
conn.ConnectionString = ConfigurationManager.ConnectionStrings["TopJobdb"].ConnectionString;
conn.Open();
SqlCommand comm = new SqlCommand();
comm.Connection = conn;
comm.CommandText = "INSERT INTO topJobUser(username, email, password)" +
" VALUES (@username, @email, @password)";
comm.Parameters.AddWithValue("@username", u.UserName);
comm.Parameters.AddWithValue("@email", u.Email);
comm.Parameters.AddWithValue("@password", u.Password);
rowsinserted = comm.ExecuteNonQuery();
}
catch (SqlException e)
{
throw e;
}
return rowsinserted;
}
}
}
以下图片为错误讯息 enter image description here
您正在捕获一个SqlException并再次抛出它。你需要处理它。 – Flaugzig
请显示错误消息'e.Message' –
知道InnerException消息以解决实际问题将是有趣的 – Steve