插入查询无效插入表单语法错误

时间:2018-04-02 01:01:20

标签: jquery sql netbeans

我一直想弄清楚我的查询有什么问题我是初学者希望以下建议是我的查询谢谢

stmt.executeUpdate ("INSERT INTO reseve1( Customer Name, Contact Number, Email 
Address, Venue, Date, Time, Price, Balance) "+ "VALUES ("+"\""+cx1+"\""+","+"\""+contactnum11+"\""+","+"\""+"\""+email1+"\""+","+"\""+"\""+ venuee+"\""+","+"\""+"\""+Date1+"\""+","+"\""+"\""+Time1+"\""+","+"\""++"\""+","+"\""+"\""+Price1+"\""+","+"\""+Balance+"\""+")");

2 个答案:

答案 0 :(得分:-1)

SqlConnection con = new SqlConnection(); con.ConnectionString =" Data Source =。\ SQLEXPRESS; Initial Catalog = University; Integrated Security = True; Pooling = False&#34 ;; string query1 =" insert into reseve1(Customer_Name,Contact_Number,Email,Address,Venue,Date,Time,Price,Balance)值(" + Customer_Name.Text +"," + Contact_Number.Text +"," + Email_Address.Text +"," + Venue.Text +"," + Date.Text +" ," + Time.Text +"," + Price.Text +"," + Balance.Text +","&#34 ;)&#34 ;; SqlCommand cmd1 = new SqlCommand(query1,con);

答案 1 :(得分:-1)

试试这个:

String sql = "INSERT INTO reseve1(Customer_Name, Contact_Number, Email_Address, Venue, Date, Time, Price, Balance) " + 
"VALUES (:cname,:cnumber,:mail,:location,:dateValue,:timeValue,:priceVal,:balanceAmount)";

SQLQuery query = session.createSQLQuery(sql);


query.setString("cname", cx1.getText());
query.setInteger("cnumber", contactnum11.getInt());
query.setString("mail", email1.getText());
query.setString("location", venuee.getText());
query.setString("dateValue", Date1);
query.setString("timeValue", Time1.getText());
query.setString("priceVal", venuee.getInt());
query.setInteger("balanceAmount", Balance.getInt());
query.executeUpdate();