Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

invalid cursor after exporting to text file 1

Status
Not open for further replies.

egentur

Programmer
Oct 12, 2005
5
DE
Hi
i have to update an application with GTD3.1
using MS SQL Server as database.
The one who wrote this app used the function SQLImmediate()
very often, but this function does not work with
OLE DB providers.

So i replaced it with my own function MySQLImmediate()
which works fine unless i open an FileSaveDialog.
After this any call to my function returns "invalid cursor".

my function looks like this

Call SqlConnect(MyhSql)
if SqlPrepare(MyhSql,sSel)
if SqlVarSetup(MyhSql)
if SqlExecute(MyhSql)

thanx for any help
 
Thanks Zathras

My Function looks like this:

Function: MySqlImmediate
Description:
Returns
Boolean:
Parameters
String: MySQLstr
Static Variables
Local variables
Sql Handle: MyhSql
Boolean: bConnect
Boolean: bOk
String: sSel
String: MyContext
Actions
Set bConnect = SqlConnect (MyhSql)
Set sSel = MySQLstr
Set bOk = SqlPrepare(MyhSql,sSel)
Set bOk = SqlContextSetToForm( MyhSql, hWndForm)
Set bOk = SqlExecute(MyhSql)
If (SalStrScan(MySQLstr,'SELECT')>-1) and (SalStrScan(MySQLstr,'INSERT')=-1)
Set bOk = SqlFetchNext(MyhSql,nFetch)
Call SqlDisconnect(MyhSql)
Return bOk


It works correct unless i open an FileDialog
i.e. for exporting data to text file,
then the function always return "invalid cursor"

as long as i do not restart my app

any idea ?

 
Hi Zathras
I forgot
it runs well under XP but not under Win2000 Prof.
 

Which statement gives the error? Step thru the code. Be sure that the connection variables haven't been stomped on somewhere near your file dialog box code. (SqlUser, SqlDatabase, SqlPassword)

You might try "beefing it up" with When SqlError statements to trap and handle the error yourself. See examples under SqlPrepare and SqlExecute in the help file.

It would also be more robust if you didn't just assume that every statement worked. Use the return values. E.g., something like
[tt]
Set bOk = False
If SqlPrepare(MyhSql,sSel)
If SqlContextSetToForm( MyhSql, hWndForm)
Set bOk = SqlExecute(MyhSql)
[/tt]
But don't stop there. Use When SqlError to trap and report the actual error received.

 
Hi Zathras

i debuged an found that the connect already fails.
but even when i set sqlDatabse, user and pw
the connect fails
 
Hi Zathras

I found a solution.

I use SqlUDL for login info.
after opening a filedialog the windowspath was set
to the location where i save the file

i have to set the SqlUDL with the application path

but with slashes not backslashes
i.e. Set SqlUDL = 'C:/somepath/myapp.udl'

that works


thanx for your help

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top