关键字过程附近的语法不正确 [英] Incorrect syntax near the keyword procedure

查看:81
本文介绍了关键字过程附近的语法不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public void GetData()
{
    try
    {
        cc.con = new SqlConnection(cs.DBCon);
        cc.con.Open();
        cc.cmd = new SqlCommand("Select RTRIM(Pay_ID),RTRIM(PaymentID) from Procedure order by PaymentID", cc.con);
        cc.rdr = cc.cmd.ExecuteReader(CommandBehavior.CloseConnection); Procedure order by PaymentID", cc.con);
        dataGridView1.Rows.Clear();
        while (cc.rdr.Read())
        {
            dataGridView1.Rows.Add(cc.rdr[0], cc.rdr[1], cc.rdr[2]);
        }
        cc.con.Close();
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message, "",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
    }
}





我的尝试:



关键字附近的语法不正确过程



What I have tried:

incorrect syntax near the keyword Procedure

推荐答案

名称 PROCEDURE 保留关键字 [ ^ ]。您需要将名称括在方括号中以使用它:

The name PROCEDURE is a reserved keyword[^] in SQL. You will need to enclose the name in square brackets to use it:
Select RTRIM(Pay_ID),RTRIM(PaymentID) from [Procedure] order by PaymentID


尝试以下代码



Try Below Code

public void GetData()
{
    try
    {
        cc.con = new SqlConnection(cs.DBCon);
        cc.con.Open();
        cc.cmd = new SqlCommand("Select RTRIM(Pay_ID),RTRIM(PaymentID) from Procedure order by PaymentID", cc.con);
        cc.rdr = cc.cmd.ExecuteReader(); // Changed Here
        dataGridView1.Rows.Clear();
        while (cc.rdr.Read())
        {
            dataGridView1.Rows.Add(cc.rdr[0], cc.rdr[1], cc.rdr[2]);
        }
        cc.con.Close();
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message, "",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
    }
}


这篇关于关键字过程附近的语法不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆