本文介绍了您的SQL语法有错误;检查与MySQL服务器版本对应的手册,以便在“UPDATE”附近使用正确的语法btechstudent_academics'SET'Tenth'= 93,'Twelveth'= 80,'Di的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试更新我的数据库,出现上面的错误..请指示我该怎么做..错误是
你的SQL语法有错误;查看对应的手册您的MySQL服务器版本正确使用'UPDATE'附近的语法btechstudent_academics'SET'Tenth'= 93,'Twelveth'= 80,'Diploma'= 0,'Gradua'在第1行
i am trying to update my database the above error appears..please suggest me what to do..error is
"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UPDATE 'btechstudent_academics' SET 'Tenth'=93,'Twelveth'=80,'Diploma'=0,'Gradua' at line 1"
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MySql.Data.MySqlClient;
using System.IO;
public partial class BtechSrtudentUpdate : System.Web.UI.Page
{
MySqlConnection conn1 = new MySqlConnection("Server=localhost;Database=test;Uid=root;Pwd=1234");
MySqlConnection conn2 = new MySqlConnection("Server=localhost;Database=test;Uid=root;Pwd=1234");
string r=" ";
protected void Page_Load(object sender, EventArgs e)
{
r = Request.QueryString["regd"];
Label2.Text = r;
TextBoxtRegd.Text = Request.QueryString["regd"];
TextBoxName.Text = Request.QueryString["name"];
txtDate.Text = Request.QueryString["Dob"];
TextBoxBatch.Text = Request.QueryString["Batch"];
TextBoxEmail.Text = Request.QueryString["Email"];
TextBoxMobile.Text = Request.QueryString["mobile"];
TextBoxParentName .Text = Request.QueryString["pname"];
TextBoxParentNumber.Text = Request.QueryString["pno"];
Branch .SelectedValue = Request.QueryString["Branch"];
TextBoxTenth.Text = Request.QueryString["Tenth"];
TextBoxTwelveth.Text = Request.QueryString["Twelveth"];
TextBoxDiploma.Text = Request.QueryString["dip"];
TextBoxGraduation.Text = Request.QueryString["grad"];
TextBoxBtech.Text = Request.QueryString["btech"];
TextBoxYeargap.Text = Request.QueryString["yeargap"];
TextBoxBacklog.Text = Request.QueryString["backlog"];
TextBoxSkills.Text = Request.QueryString["Skills"];
}
protected void Button1_Click(object sender, EventArgs e)
{
string r = Request.QueryString["regd"];
conn1.Open();
//conn2.Open();
Label2.Text = " "+TextBoxName.Text +" "+TextBoxTwelveth .Text ;
Label2.Visible = true;
string sql2 = "(UPDATE 'btechstudent_academics' "+"SET 'Tenth'=" + Convert.ToDouble(TextBoxTenth.Text) + ",'Twelveth'=" + Convert.ToDouble(TextBoxTwelveth.Text) + ",'Diploma'=" + Convert.ToDouble(TextBoxDiploma.Text) + ",'Graduation'=" + Convert.ToDouble(TextBoxGraduation.Text) + ",'Btech'=" + Convert.ToDouble(TextBoxBtech.Text) + ",'Yeargap'=" + Convert.ToInt32(TextBoxYeargap.Text) + ",'Backlog'=" + Convert.ToInt32(TextBoxBacklog.Text) + ",'Skills'='" + TextBoxSkills.Text + "' where [Regd_no]='"+TextBoxtRegd .Text +"')";
// string sql1 = "(UPDATE btechstudent_details SET [Sname]='" + TextBoxName.Text + "',[DOB]='" + txtDate.Text + "',[Batch]=" + Convert.ToInt16(TextBoxBatch.Text) + ",[Email]='" + TextBoxEmail.Text + "',[Phone]='" + TextBoxMobile.Text
// + "',[Parents_name]='" + TextBoxParentName.Text + "',[Parents_Number]='" + TextBoxParentNumber.Text + "',[Branch]='"+Branch.SelectedItem .ToString () +"' WHERE [Regd_no]='"+ TextBoxtRegd.Text +"')";
// string sql2 = "(update btechstudent_academics where Regd_no='" + TextBoxtRegd.Text + "')";
MySqlCommand cmd2 = new MySqlCommand(sql2, conn1);
//MySqlCommand cmd2 = new MySqlCommand(sql2, conn2);
try
{
Response.Write("HI");
cmd2.ExecuteNonQuery();
}
catch (Exception x)
{ Label1.Text = " " + x.Message; }
finally
{
conn1.Close();
}
}
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
}
protected void TextBoxBacklog_TextChanged(object sender, EventArgs e)
{
}
protected void TextBoxTenth_TextChanged(object sender, EventArgs e)
{
}
protected void TextBox9_TextChanged(object sender, EventArgs e)
{
}
}
推荐答案
这篇关于您的SQL语法有错误;检查与MySQL服务器版本对应的手册,以便在“UPDATE”附近使用正确的语法btechstudent_academics'SET'Tenth'= 93,'Twelveth'= 80,'Di的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!