Jump to content

Using SQLCmd with AutoIt


 Share

Recommended Posts

For those of you using SQLCmd to run queries from AutoIt - is the logfile the only place you can get the results of your query, or can you read them directly into a variable somehow? I'm just not familiar enough yet with AutoIt to know for sure I'm not missing something, and it seems ever so much more efficient to grab them out of memory than having to write them to disk and then read them back...

Thanks!

LadyLong

.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo"I came to realize that life lived to help others is the only one that matters. This is my highest and best use as a human." -- Ben Stein
Link to comment
Share on other sites

...can you read them directly into a variable somehow?

<{POST_SNAPBACK}>

To sort of illustrate what I mean, I tried this:

Run('sqlcmd\sqlcmd.exe /user soapuser /pass soapware /db "SW Charts" /command "use sw_charts select last_name=convert(varchar(15), last_name) from gen_demo"')

$result=WinGetText("")

MsgBox(0, "Results", $result)

But result I get is from the window where I executed the script, rather than the DOS window that briefly flashes while the query is executing. I figure it's probably because the WinGetText command gets issued after the query has already finished, so the window it was in no longer exists.

Among the 57 or so other ideas I tried that failed was this one:

ClipPut(Run('sqlcmd\sqlcmd.exe /user soapuser /pass soapware /db "SW Charts" /command "use sw_charts select last_name=convert(varchar(15), last_name) from gen_demo"'))

$result=ClipGet()

MsgBox(0, "Results", $result)

That gives me a number, not the results of my query. So I'm still stumped, I guess... am I attempting the impossible, or just missing the key? Help!

LadyLong :lmao:

.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo"I came to realize that life lived to help others is the only one that matters. This is my highest and best use as a human." -- Ben Stein
Link to comment
Share on other sites

Currently impossible*. In a future version it'll be possible to pipe the output from a DOS session into a variable, but that's not yet available, so the only safe alternative is to redirect to a file (You can do screen-scrapes, but thats a bit harder).

* I use that loosely, it very well may be possible via DllCall(). I don't think anybody has actually tried to implement the necessary code in that manner.

Edited by Valik
Link to comment
Share on other sites

Currently impossible*.  In a future version it'll be possible to pipe the output <snip>

<{POST_SNAPBACK}>

Re: Future piping of output: Cool!

Re: Screen-scrapes: Ok, now I am obligated to request further information. Scraping screens is not something I'm familiar with, and it sounds just weird enough to be intriguing.

Re: DllCall(): Hmmm. Wandering around somewhere in the back of my brain is a vague reference to a warning about setting traps for tigers, lest you catch one. She ponders whether she's brave enough to call a Dll... what if one answers?

Aww, heck. I'm on a roll -- El Doctor LOVED his new little timesaver (yesterday's project). Maybe I'll go see if I can catch myself a Dll.

Thanks, Valik!

LadyLong

.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo"I came to realize that life lived to help others is the only one that matters. This is my highest and best use as a human." -- Ben Stein
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...