3

Here is the error:

Dynamic SQL Error    
SQL error code = -104    
Token unknown - line 1, column 162    
VALUE

Here is the code:

using (FbDataAdapter da = new FbDataAdapter(@"SELECT DOC_ITEMS.ID, PRODUCTS.PRODUCTKEY, PRODUCTS.NAME, DOC_ITEMS.QUANTITY, UNITS.UNIT, DOC_ITEMS.PRICE, DOC_ITEMS.TAX, (DOC_ITEMS.PRICE * DOC_ITEMS.QUANTITY) AS VALUE
                        FROM PRODUCTS INNER JOIN
                        DOC_ITEMS ON PRODUCTS.PRODUCTID = DOC_ITEMS.PRODUCTID INNER JOIN
                        UNITS ON PRODUCTS.UNITID = UNITS.UNITID
                        WHERE (DOC_ITEMS.DOCUMENTID = @DocumentID)", con))

{
    da.SelectCommand.Parameters.AddWithValue("@DocumentID", documentId);

    DataTable dt = new DataTable();
    da.Fill(dt);
    dataGridView1.DataSource = dt;

    dataGridView1.Columns["PRODUCTKEY"].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
    dataGridView1.Columns["ID"].Visible = false;
    dataGridView1.Columns["NAME"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
    dataGridView1.Columns["QUANTITY"].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
    dataGridView1.Columns["QUANTITY"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
    dataGridView1.Columns["UNIT"].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
    dataGridView1.Columns["PRICE"].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
    dataGridView1.Columns["PRICE"].DefaultCellStyle.Format = "0.00 $";
    dataGridView1.Columns["TAX"].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
    dataGridView1.Columns["TAX"].DefaultCellStyle.Format = "0\\%";
    dataGridView1.Columns["VALUE"].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
    dataGridView1.Columns["VALUE"].DefaultCellStyle.Format = "0.00 $";
}

When I run this command through my database directly it is working ok but inside my c# code it drops this error.

3 Answers 3

2

Use ""VALUE"" with double quotes since one quote will close your string.

Sign up to request clarification or add additional context in comments.

Comments

1

VALUE is a reserved word in Firebird, this means it can't be used in a query as an object name. You need to either use a different name, or explicitly quote it as "VALUE", so the query parser knows it is not a reserved word.

Comments

0

I'm trying to create a table in my Interbase database.

Dynamic SQL Error SQL error code = -104 Unexpected end of command

and this is my table :

CREATE TABLE Medecin(
    Code Integer ,
    Nom varchar(30) ,
    prénom varchar(30) ,
    spécialité varchar(30) ,
    Adresse varchar(50) ,
    telephone varchar(14)
);

What is wrong here?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.