Help Again Please
Michael de Haan
mdeh at earthlink.net
Tue Mar 23 21:56:27 CST 2004
Ruslan,
Still having a hard time with the issue of inserting a new record into
a table (VRB4):
2 Questions immediately come to mind.
1)
The indexes in the array are numbered 0,1,2 etc ie zero based.
So, using :1,:2,:3 in the "Values" statement is Correct?
as in --->
((VALUES (:1, :2, :3) &
dim Binds(-1) as String
Binds.append '12123'
Binds.append 'bu'
Binds.append '23' ))
2)
Please help with the line;
db.SqlExecute( mySQL, Binds )
In the ref (VALENTINA for REALbasic Reference), this is shown as:
SQLExecute( Query as String, [Binds() as String] ) as Integer.
When I try and write the line "db.SqlExecute( mySQL, Binds )" it will
not execute unless it is written as a function that returns an integer,
(that is the error message generated if no integer variable is
supplied)
as in RecCount=db.SqlExecute( mySQL, Binds ).
So, what does compile, but still does not work is the following:
RecCount=myDB.sqlExecute(mySqL, theArray)
where mySqL is
"INSERT INTO iCpts ( cCode, cDesc, cVal ) VALUES (:1, :2, :3)"
and theArray is
0 '12123'
1 'bu'
etc etc
I have tried :
-- changing the values of VALUES to :0 etc :1 etc
-- removing the double quotations on either end of the mySqL string
Not sure what to try next?
Thanks
Michael.
>>>>>>>>>>>>>>>>>>>>>>>>>>
> Ruslan,
>
> Is there any obvious reason to you why this syntax is not working?
>
> RecCount=myDB.sqlExecute(MySQL)
>
> where MySQL is:
>
> "INSERT INTO iCpts ( cCode, cDesc, cVal ) VALUES (:1, :2, :3) binded
> with { "12123","bu","23"}"
Yes. Must be:
mySQL = "INSERT INTO iCpts ( cCode, cDesc, cVal ) VALUES (:1, :2, :3)"
And later, I assume you use V4RB:
dim Binds(-1) as String
Binds.append '12123'
Binds.append 'bu'
Binds.append '23'
db.SqlExecute( mySQL, Binds )
I.e. Binds is true array of strings.
> and where
>
> iCpts is a table name
>
> cCode, cDesc, cVal are the field description
>
>
> as in .........
>
> CodeC=new vString("cCode", 8)
> DescC=new vVarChar("cDesc", 504)
> cVal=new vString("cVal", 2)
More information about the Valentina
mailing list