问题是我的代码没有使用 asp.net c# 将新记录插入/保存到我的 SQL Server 数据库中,并且没有给我任何错误。
这是我的代码:
public partial class AddNews_AddNews : System.Web.UI.Page
{
protected SqlConnection _connection;
protected SqlCommand _command;
protected SqlDataAdapter _adp;
protected System.Data.DataTable _tbl;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click1(object sender, EventArgs e)
{
prepareConnection();
_command.CommandText = "INSERT INTO" + drbdlSection.SelectedItem + "(Title,Contect) VALUES (" + titleTextBox.Text + "," + CKEditor1.Text + ");";
}
protected void prepareConnection()
{
_connection = new SqlConnection(@"Data Source=localhost;Initial Catalog=BrainStorms;User ID=sa;Password=xxx");
_connection.Open();
_command = new SqlCommand();
_command.Connection = _connection;
}
}