Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

invalid cursor after exporting to text file

invalid cursor after exporting to text file

invalid cursor after exporting to text file

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

RE: invalid cursor after exporting to text file

Looks like you forgot SqlDisconnect(MyhSql)

RE: invalid cursor after exporting to text file

Thanks Zathras

My Function looks like this:

Function: MySqlImmediate
        String: MySQLstr
    Static Variables
    Local variables
        Sql Handle: MyhSql
        Boolean: bConnect
        Boolean: bOk
        String: sSel
        String: MyContext
        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 ?

RE: invalid cursor after exporting to text file

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

RE: invalid cursor after exporting to text file

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

   Set bOk = False
   If SqlPrepare(MyhSql,sSel)
     If SqlContextSetToForm( MyhSql, hWndForm)
       Set bOk = SqlExecute(MyhSql)

But don't stop there.  Use When SqlError to trap and report the actual error received.

RE: invalid cursor after exporting to text file

Hi Zathras

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

RE: invalid cursor after exporting to text file

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close