本文介绍了“('。?附近的语法不正确?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

{

    {
        try
        {
            cn.Open();
            int i = 0;

            String ads = "INSERT into TableForce (Id,Name_of_the_customer,Certificate_No,Name_of_the_instrument,Received_on,";

            ads = ads + "Calibrated_On,Calibration_due_dat(e),Make,Model,Mode_of_Calibration,Serial_No,Identification_No,";

            ads=ads+"Temperature,Capacity_,Calibrated_Range,Resolution,Condition_on_receipt,Location,Relative_humidity,";

            ads=ads+"Calibration_done_as_per_procedure_no,Standard_procedure,Nomenclature,Range_from,Certificate_Number,";

            ads=ads+"Uncertainity,Capacity,Dial_No,Validity,Nomenclature-,Range_from-,Certificate_Number-,Uncertainity-,";

            ads=ads+"Capacity-,Dial_No-,Validity-,Indicated_force,Standard_reading,Corrected_reading,Test_position,Mean,";

            ads=ads+"Error,Repeatablity,Minimum_readable_resolution_of_the_indicator,Expanded_Uncertainty,";

            ads = ads + "Certificate Issue dat(e),Location of Calibration,Calibrated By,Authorized By,Load1,Load2,relative_resolution,mt,rt,mc,rze)";
            ads = ads + "values('" + iDTextBox.Text + "','" + name_of_the_customerRichTextBox.Text + "','";
            ads = ads + certificate_NoTextBox.Text + "','" + name_of_the_instrumentTextBox.Text + "','" + received_onDateTimePicker.Text;
            ads = ads + "','" + calibrated_OnDateTimePicker.Text + "','" + calibration_due_dat_e_DateTimePicker.Text + "','";
            ads = ads + makeTextBox.Text + "','" + modelTextBox.Text + "','" + mode_of_CalibrationTextBox.Text;
            ads = ads + "','" + serial_NoTextBox.Text + "','" + identification_NoTextBox.Text + "','";
            ads = ads + temperatureTextBox.Text + "','" + capacity_TextBox.Text + "','" + calibrated_RangeTextBox.Text;

            ads = ads + resolutionTextBox.Text + "','" + condition_on_receiptTextBox.Text + "','" + locationTextBox.Text;
            ads = ads + relative_humidityTextBox.Text + "','" + calibration_done_as_per_procedure_noTextBox.Text + "','" + standard_procedureTextBox.Text;
            ads = ads + nomenclatureTextBox.Text + "','" + range_fromTextBox.Text + "','" + certificate_NumberTextBox.Text;
            ads = ads + textBox8.Text + "','" + capacityTextBox.Text + "','" + dial_NoTextBox.Text;
            ads = ads + validityDateTimePicker.Text + "','" + nomenclature_TextBox.Text + "','" + range_from_TextBox.Text;

            ads = ads + certificate_Number_TextBox.Text + "','" + textBox16.Text + "','" + capacity_TextBox1.Text;
            ads = ads + dial_No_TextBox.Text + "','" + validity_DateTimePicker.Text + "','" + textBox4.Text;
            ads = ads + textBox3.Text + "','" + textBox17.Text + "','" + textBox1.Text;
            ads = ads + textBox2.Text + "','" + textBox6.Text + "','" + textBox5.Text;
            ads = ads + textBox11.Text + "','" + textBox7.Text + "','" + certificate_Issue_dat_e_DateTimePicker.Text;

            ads = ads + location_of_CalibrationDomainUpDown.Text + "','" + calibrated_ByTextBox.Text + "','" + authorized_ByTextBox.Text;
            ads = ads + load1TextBox.Text + "','" + load2TextBox.Text + "','" + textBox9.Text;
            ads = ads + textBox24.Text + "','" + textBox25.Text + "','" + textBox13.Text;
            ads = ads + textBox12.Text;
            ads=ads+ "');";
            SqlCommand cmd = new SqlCommand(ads, cn);
            MemoryStream stream = new MemoryStream();
            i = cmd.ExecuteNonQuery();
            if (i > 0)
            {
                MessageBox.Show("DATA SAVED");
            }
            iDTextBox.Text = Convert.ToString(Convert.ToDouble(iDTextBox.Text) + 1);
            cn.Close();
            }
        finally
        {
            cn.Close();
        }
    }
}





我尝试了什么:



当我试图点击保存按钮时它会显示'('。



What I have tried:

while i tried to click save button it shows Incorrect syntax near '('.

推荐答案


ads=ads+"Uncertainity,Capacity,Dial_No,Validity,Nomenclature-,Range_from-,Certificate_Number-,Uncertainity-,";

所以试试:

So try:

ads=ads+"Uncertainity,Capacity,Dial_No,Validity,[Nomenclature-],[Range_from-],[Certificate_Number-],[Uncertainity-],";

虽然我个人而言,我会更改名称:以特殊字符结尾并不是一个好主意。

请 - 为您的自己的缘故停止使用Visual Studio默认名称 - 你可能还记得今天的TextBox8是手机号码,但是当你必须在三周内修改它时,你会这样吗?使用描述性名称 - 例如tbMobileNo - 您的代码变得更容易阅读,更自我记录,更易于维护 - 并且编码速度更快,因为Intellisense可以通过三次击键来tbMobile,其中TextBox8需要思考大概和8次击键...

Though personally, I would change the names: ending with a special character is not a good idea.
And please - for your own sake stop using Visual Studio default names for everything - you may remember that "TextBox8" is the mobile number today, but when you have to modify it in three weeks time, will you then? Use descriptive names - "tbMobileNo" for example - and your code becomes easier to read, more self documenting, easier to maintain - and surprisingly quicker to code because Intellisense can get to to "tbMobile" in three keystrokes, where "TextBox8" takes thinking about and 8 keystrokes...



这篇关于“('。?附近的语法不正确?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 20:12