asp在编译中myCmd.ExecuteNonQuery();'16' 附近有语法错误。 字符串 ')' 后的引号不完整。
publicpartialclass走进四维:System.Web.UI.Page{SqlConnectionmyConn;protectedvoidPage_Load(...
public partial class 走进四维 : System.Web.UI.Page
{
SqlConnection myConn;
protected void Page_Load(object sender, EventArgs e)
{
string message_dns = Convert.ToString(ConfigurationManager.ConnectionStrings["ConnectionString"]);
myConn = new SqlConnection(message_dns);
}
protected void Button1_Click(object sender, EventArgs e)
{
string sql_string;
if (TextBox1.Text.Trim() != "" && TextBox2.Text.Trim() != "" && TextBox2.Text.Trim() != "" && TextBox3.Text.Trim() != "" && TextBox4.Text.Trim() != "" && TextBox5.Text.Trim() != "" && TextBox6.Text.Trim() != "" && TextBox7.Text.Trim() != "" && TextBox8.Text.Trim() != "")
{
DateTime tt = System.DateTime.Now;
sql_string = "insert into message (message_com_nam,message_nam,message_pho,message_fax,message_add,message_email,message_title,message_content) values (" + tt.ToString() + "','" + TextBox1.Text.Trim() + "','" + TextBox2.Text + "','" + TextBox1.Text.Trim() + "','" + TextBox3.Text.Trim() + "','" + TextBox4.Text.Trim() + "','" + TextBox5.Text.Trim() + "','" + TextBox6.Text.Trim() + "','" + TextBox7.Text.Trim() + "','" + TextBox8.Text.Trim() + "')";
}
else
{
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
TextBox4.Text = "";
TextBox5.Text = "";
TextBox6.Text = "";
TextBox7.Text = "";
TextBox8.Text = "";
Response.Write("<script>window.alert('请填写完整!!');</script>");
return;
}
SqlCommand myCmd = new SqlCommand(sql_string, myConn);
myConn.Open();
myCmd.ExecuteNonQuery();
myConn.Close();
this.Server.Transfer("~/news/在线留言.aspx");
}
} 展开
{
SqlConnection myConn;
protected void Page_Load(object sender, EventArgs e)
{
string message_dns = Convert.ToString(ConfigurationManager.ConnectionStrings["ConnectionString"]);
myConn = new SqlConnection(message_dns);
}
protected void Button1_Click(object sender, EventArgs e)
{
string sql_string;
if (TextBox1.Text.Trim() != "" && TextBox2.Text.Trim() != "" && TextBox2.Text.Trim() != "" && TextBox3.Text.Trim() != "" && TextBox4.Text.Trim() != "" && TextBox5.Text.Trim() != "" && TextBox6.Text.Trim() != "" && TextBox7.Text.Trim() != "" && TextBox8.Text.Trim() != "")
{
DateTime tt = System.DateTime.Now;
sql_string = "insert into message (message_com_nam,message_nam,message_pho,message_fax,message_add,message_email,message_title,message_content) values (" + tt.ToString() + "','" + TextBox1.Text.Trim() + "','" + TextBox2.Text + "','" + TextBox1.Text.Trim() + "','" + TextBox3.Text.Trim() + "','" + TextBox4.Text.Trim() + "','" + TextBox5.Text.Trim() + "','" + TextBox6.Text.Trim() + "','" + TextBox7.Text.Trim() + "','" + TextBox8.Text.Trim() + "')";
}
else
{
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
TextBox4.Text = "";
TextBox5.Text = "";
TextBox6.Text = "";
TextBox7.Text = "";
TextBox8.Text = "";
Response.Write("<script>window.alert('请填写完整!!');</script>");
return;
}
SqlCommand myCmd = new SqlCommand(sql_string, myConn);
myConn.Open();
myCmd.ExecuteNonQuery();
myConn.Close();
this.Server.Transfer("~/news/在线留言.aspx");
}
} 展开
2个回答
展开全部
insert into message (message_com_nam,message_nam,message_pho,message_fax,message_add,message_email,message_title,message_content) values (‘" + tt.ToString() + "','" + TextBox1.Text.Trim() .ToString() + "','" + TextBox2.Text .Trim() .ToString() + "','" + TextBox1.Text.Trim() .ToString() + "','" + TextBox3.Text.Trim() .ToString() + "','" + TextBox4.Text.Trim() .ToString() + "','" + TextBox5.Text.Trim() .ToString() + "','" + TextBox6.Text.Trim() .ToString() + "','" + TextBox7.Text.Trim() .ToString() + "','" + TextBox8.Text.Trim() .ToString() + "')";
下次写代码尽量写整齐统一点,代码是给自己看的。你缺了一个“’”,我帮你加了,你就复制这段就好了,试试看。
下次写代码尽量写整齐统一点,代码是给自己看的。你缺了一个“’”,我帮你加了,你就复制这段就好了,试试看。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询