cmd.ExecuteNonQuery();出错了
usingSystem;usingSystem.Data;usingSystem.Data.SqlClient;//加入的命名空间usingSystem.Configur...
using System;
using System.Data;
using System.Data.SqlClient;//加入的命名空间
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btn_SendMessage_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection(@"server=(local)\SQLEXPRESS;database=GuestBook;Trusted_Connection=True");
string Sql = "INSERT INTO tbGuestBook(UserName,PostTime,Message,IsReplied,Reply)values('test','2008-11-23 21:45','编程快乐',0,'')";
SqlCommand CMD = new SqlCommand(Sql, conn);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
}
}
我刚开始学~~照书上打的啊~~那个tbGuestBook数据库我建了啊~~不太懂你说的意思~~我菜鸟一只~~嘿嘿
那条语句能执行通~~可以为空~~类型都区配~~当我将//cmd.ExecuteNonQuery();的时候就会提示,无法打开登录所请求的数据库 "GuestBook"。登录失败。
用户 '20081022-0836\Administrator' 登录失败。我是sqlsever身份验证连的~~连上了啊~~实在不明白了~~ 展开
using System.Data;
using System.Data.SqlClient;//加入的命名空间
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btn_SendMessage_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection(@"server=(local)\SQLEXPRESS;database=GuestBook;Trusted_Connection=True");
string Sql = "INSERT INTO tbGuestBook(UserName,PostTime,Message,IsReplied,Reply)values('test','2008-11-23 21:45','编程快乐',0,'')";
SqlCommand CMD = new SqlCommand(Sql, conn);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
}
}
我刚开始学~~照书上打的啊~~那个tbGuestBook数据库我建了啊~~不太懂你说的意思~~我菜鸟一只~~嘿嘿
那条语句能执行通~~可以为空~~类型都区配~~当我将//cmd.ExecuteNonQuery();的时候就会提示,无法打开登录所请求的数据库 "GuestBook"。登录失败。
用户 '20081022-0836\Administrator' 登录失败。我是sqlsever身份验证连的~~连上了啊~~实在不明白了~~ 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询