Ошибка dynamic sql error sql

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.

asked Nov 19, 2017 at 11:06

UProduction's user avatar

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

answered Nov 19, 2017 at 11:23

Aleksa Ristic's user avatar

Aleksa RisticAleksa Ristic

2,3743 gold badges23 silver badges53 bronze badges

0

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.

answered Nov 19, 2017 at 11:56

Mark Rotteveel's user avatar

Mark RotteveelMark Rotteveel

99.2k188 gold badges137 silver badges192 bronze badges

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?

rollstuhlfahrer's user avatar

answered Apr 3, 2018 at 8:39

Abdou 's user avatar

Модератор: Модераторы

не понятная ошибка при выполнении SQL запроса

постоянно возникает при выполнении запроса

Код: Выделить всё
MainForm.SQLMain.SQL.Text := 'SELECT * FROM DOC WHERE UPPER(DOC_ABOUT) LIKE UPPER(''%' + Editm.Text + '%'') ORDER BY ID DESC';

ошибка
Dynamic SQL Error
SQL error code = -804
Incorrect values within SQLDA structure.

причем в аналогичном запросе

Код: Выделить всё
SQLQuery1.SQL.Text := 'SELECT * FROM ADAT WHERE A_ID!=:ID AND UPPER(A_NAME) LIKE UPPER(''%' + EditSearch.Text + '%'') ORDER BY A_NAME';

все выполняется нормально

работаю на локальной машине FB 1.5

а если дополнить первый запрос любым параметром, то выполнение проходит нормально

NewUser
новенький
 
Сообщения: 97
Зарегистрирован: 08.05.2007 13:28:40

Сообщение v-t-l » 11.07.2007 16:05:24

А DOC_ABOUT не BLOB?

v-t-l
энтузиаст
 
Сообщения: 719
Зарегистрирован: 13.05.2007 16:27:22
Откуда: Belarus

Сообщение NewUser » 11.07.2007 17:23:34

нет, поля varchar

NewUser
новенький
 
Сообщения: 97
Зарегистрирован: 08.05.2007 13:28:40

Сообщение Attid » 11.07.2007 22:10:45

для начало идем учить что такое параметизированый запрос

потом проверяем работу запроса в эксперте.

потом

if работает в эксперте them

приводим ddl таблицы

else

оброщаемся на форум птички.

Аватара пользователя
Attid
долгожитель
 
Сообщения: 2585
Зарегистрирован: 27.10.2006 17:29:15
Откуда: 44°32′23.63″N 41°2′25.2″E
  • Профиль
  • Сайт
  • ICQ


Вернуться в Lazarus

Кто сейчас на конференции

Сейчас этот форум просматривают: Google [Bot] и гости: 25

Hi,

I am getting the error below when Adding a Child. The size of the EPIM FRee database is 7G = 7,086,788KB. I am not doing anything special. I am only adding a new child. Have a reach a limit of some sort? At the moment, I can still read current notes and stuff, delete etc. but can’t add. I’ve empty the trash, run optimize and still the same problem. I thought I can delete some, empty trash and then delete but it is the same error message. I am now trying to make a copy of the current file and then delete lots to size it down and se if that helps. Hopefully it does but then that means I am hitting some kind of limits somewhere, number of notes :(

Any advice much appreciated. Thanks in advance.

There was an error during the execution of this program.
Click «Send» to submit the report to the developer. Please also provide any steps necessary to reproduce the problem.

Dynamic SQL Error
SQL error code = -303
arithmetic exception, numeric overflow, or string truncation.

——————————————————————————
Exception log with detailed tech info. Generated on 25/09/2014 2:05 p.m..
You may send it to the application vendor, helping him to understand what had happened.
Application title: [ Name of the EPIM file and the EPIM Executable = Essential PImportEssentialPIM.exe ]
Application: EssentialPIM Portable 5.82
——————————————————————————
Exception class: EIBInterBaseError
Exception message: Dynamic SQL Error
SQL error code = -303
arithmetic exception, numeric overflow, or string truncation.
Exception address: 00874014
——————————————————————————
Main thread ID = 9664
Exception thread ID = 9664
——————————————————————————
Object Logs:
12839646 SetViewMode OK
12839521 SetViewMode 3
12837837 SetViewMode OK
12837649 SetViewMode 0
12823984 DBOpen

——————————————————————————
Active Controls:
12863873 ExceptionDialog TextMemo
12859240 NotePropDialog Panel1 NameEd
12857181 MainForm FormPan FormPan2 NotesForm TreesTC NotesVT
12855652 MainForm FormPan FormPan2 NotesForm RichEditFrame1 TabsTC RichViewEdit
12855137 AdvertForm HtmlViewer1 TPaintPanel ThtTabControl
12854903 MainForm FormPan FormPan2 NotesForm RichEditFrame1 TabsTC RichViewEdit
12837337 MainForm
12824186 PassDialog GroupBox1 PasswordEd

——————————————————————————
Exception stack
Stack list, generated 25/09/2014 2:05 p.m.
[0087400F] IB.IBDataBaseError (Line 420, «IB.pas» + 39) [0089804E] IBDatabase.TIBTransaction.Call (Line 1665, «IBDatabase.pas» + 11) [0087BB21] IBSQL.TIBSQL.Call (Line 2483, «IBSQL.pas» + 3) [0087BE04] IBSQL.TIBSQL.ExecQuery (Line 2556, «IBSQL.pas» + 50) [00D44166] SyncObj.TNote.StoreUserDataToSQL (Line 5310, «SyncObj.pas» + 7) [0054DB5F] Vcl.Controls.TControl.Click (Line 7340, «Vcl.Controls.pas» + 9)
——————————————————————————
Call stack for main thread
Stack list, generated 25/09/2014 2:05 p.m.
(000460F4) [775F70F4]
——————————————————————————
System : Windows 7 Professional, Version: 6.1, Build: 1DB1, «Service Pack 1»
Memory: 2993; free 1891
Display : 1920×1080 pixels, 32 bpp, 96 PPI
——————————————————————————

  • Remove From My Forums
  • Вопрос

  • I can’t figure out why this dynamic SQL query is throwing the following error …

    DECLARE @WorksheetDate date;
    SET @sqlStr = N'SELECT @WorksheetDate = CAST(ltrim(rtrim(F2)) as date)
    	FROM OPENROWSET(''Microsoft.ACE.OLEDB.12.0''
    	,''Excel 8.0; Database=' + @FromFile + ''' 
    	,''SELECT * FROM [Sheet1$] WHERE F1 like ''''AUM as of%'''''');'
    EXEC sp_executesql @sqlStr, N'@WorksheetDate date OUTPUT', @WorksheetDate OUT	

    Error #137: «Must declare the scalar variable «@WorksheetDate».

    Any help?


    Darrell H Burns

Понравилась статья? Поделить с друзьями:
  • Ошибка dynamic link adobe media encoder
  • Ошибка dump physical memory
  • Ошибка dtsc volvo
  • Ошибка dts жесткого диска
  • Ошибка dtc922913 рено флюенс