Skip to Content
author's profile photo Former Member
Former Member

SQL: Syntax using DI...(Insert)

Hi, I am a trying to make an Insert with the DI in the table (OPRJ), But I get an SQL Error for the sintaxis, can any one help me please, I am a beginner with the DI.

Here is the code.....

Case et_ITEM_PRESSED

If pVal.ItemUID = "EndCustBtn" Then

Set oItem = oTmpForm.Items.Item("74")

Set oEditText = oItem.Specific

lDocNum = CLng(oEditText.String)

Set oItem = oTmpForm.Items.Item("50")

Set oEditText = oItem.Specific

lDocEntry = CStr(oEditText.String)

Private Sub Update()

Dim i As Long

Dim oCode1 As SAPbouiCOM.EditText

Dim oName1 As SAPbouiCOM.EditText

Dim oCode2 As SAPbouiCOM.EditText

Dim oName2 As SAPbouiCOM.EditText

oRecordset.DoQuery "Insert INTO OPRJ (PrjCode, PrjName) VALUES (lDocNum,lDocEntry )"

-


I Get the error, with tha variable lDocNum, and lDocEntry, how can i put it, in ordenr to execute the SQL.

Thank's

Message was edited by: Frank Moebius

Hi Natalia, though triggered in a UI event handler, your question is about DI; I changed that to avoid confusion. I hope you don't mind. Frank

Add comment
10|10000 characters needed characters exceeded

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on May 21, 2004 at 08:07 AM

    Hi Natalia,

    It's because the database is looking for the variables when it tries to execute the SQL and they don't exist in the database, only in your code.

    It's the values of IDocNum and IDocEntry that you want to build up the INSERT string.

    Try this:

    oRecordset.DoQuery "Insert INTO OPRJ (PrjCode, PrjName) VALUES ('" & lDocNum & "', '" & lDocEntry & "')"

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 19, 2004 at 10:26 AM

    Hi Natalia

    You've got the error because SBO adds "FOR BROWSE" at the end of the SQL string in the DoQuery (I don't know why). There are 2 ways to update SBO table (not user-defined):

    1. Work with appropriate BusinessObject (if it exist)

    2. Open your own SQL connection, make SQL command object and execute it

    That's all

    Best regards,

    Mark

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 20, 2004 at 03:07 PM

    Hi,

    PrjName is a string field

    your variable lDocEntry to enclose with quotation marks

    "Insert INTO OPRJ (PrjCode, PrjName) VALUES (lDocNum,'lDocEntry' )"

    bst rgrd

    Add comment
    10|10000 characters needed characters exceeded