ASP.NET sqlcmd.ExecuteNonQuery();老师报错 Incorrect syntax near 'vaules'.怎么办 难道是我的配置不对
usingSystem;usingSystem.Configuration;usingSystem.Data;usingSystem.Linq;usingSystem.W...
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class UseExecuteNonQuery:System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btn_Click(object sender, EventArgs e)
{
string strA = Textbox1.Text.ToString();
string strB = Textbox2.Text.ToString();
SqlConnection sqlcon = new SqlConnection();
sqlcon.ConnectionString = "Data Source=.;uid=sa;pwd=1234567; Initial Catalog=Test; ";
sqlcon.Open();
string strInsert = string.Format("insert into uuu(user_name,user_password) vaules('{0}','{1}')", strA, strB);
SqlCommand sqlcmd = new SqlCommand(strInsert,sqlcon);
sqlcmd.ExecuteNonQuery();
sqlcon.Close();
Label1.Text = "OK";
}
} 展开
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class UseExecuteNonQuery:System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btn_Click(object sender, EventArgs e)
{
string strA = Textbox1.Text.ToString();
string strB = Textbox2.Text.ToString();
SqlConnection sqlcon = new SqlConnection();
sqlcon.ConnectionString = "Data Source=.;uid=sa;pwd=1234567; Initial Catalog=Test; ";
sqlcon.Open();
string strInsert = string.Format("insert into uuu(user_name,user_password) vaules('{0}','{1}')", strA, strB);
SqlCommand sqlcmd = new SqlCommand(strInsert,sqlcon);
sqlcmd.ExecuteNonQuery();
sqlcon.Close();
Label1.Text = "OK";
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询