PC SOFT

PROFESSIONAL NEWSGROUPS
WINDEVWEBDEV and WINDEV Mobile

Home → WINDEV 2024 → [WD24] SQL OLE DB Insert into statement breaking query output.
[WD24] SQL OLE DB Insert into statement breaking query output.
Started by Robert, Apr., 15 2019 9:23 PM - 1 reply
Registered member
105 messages
Posted on April, 15 2019 - 9:23 PM
I was having some trouble getting a SQL stored procedure to work, so I wrote a little program that just takes SQL code input and runs it against a server, and returns the first column of the first row returned.

Nothing fancy.
nConnection is int = SQLConnect(sServer,sUser, sPassword, sDatabase, "OLEDB" ,hOledbSQLServer,)
sSQL is string = EDT_NoName1

bRes is boolean = SQLExec(sSQL,"QRY_Query")
sResult is string

IF bRes = False THEN
SQLInfo("QRY_Query")
Info(SQL.MesError)
RETURN
END

IF SQLFetch("QRY_Query") <> 0 THEN
SQLInfo("QRY_Query")
Info(SQL.MesError)
RETURN
END
Info(SQLGetCol("QRY_Query",1))
SQLClose("QRY_Query")
SQLDisconnect()


If you run a simple select query, such as:
SELECT 'Done'


You get the expected output.

However, if your code has an INSERT INTO statement in it, such as within a stored procedure, the output doesn't return any records.
INSERT INTO TestTbl(SNo,SetupNumber) Values(1,2)
SELECT 'Done'

The insert into code does execute, but something with the return value of the SQL call is getting erased, or corrupted, or something.

Am I doing something wrong?
If anyone has any pointers, it'd be greatly appreciated.
Message modified, April, 15 2019 - 9:26 PM
Posted on August, 29 2023 - 4:36 PM
Same problem here, in Windev28...
Looking for solution.

No problem when using native access but not working with OLEDB