Jump to content

SQL database topic


mctforhire
 Share

Recommended Posts

ok, I have tried ever example that I can find here, but I am at a loss...

I need to connect to a SQl database selct some data from it into a variable, then use the variable and update the database at the end.

So far, I can't even select...argh!

Here is my code, I tried to simpify everything I could find....

I came up with:

$adCN = ObjCreate ("ADODB.Connection")

$adCN.Open ("DRIVER={SQL Server};SERVER=dba;DATABASE=tc;uid=TC_user;pwd=password;") ;

$adCN.Execute("SELECT notam FROM notamlist ")

$adCN.Close

and I am getting

C:\proxy.au3 (43) : ==> Unable to parse line.:

which is the adcn.execute line

Help please!!!!! Thanks!

Link to comment
Share on other sites

Hi mctforhire,

ok, I have tried ever example that I can find here, but I am at a loss...

I need to connect to a SQl database selct some data from it into a variable, then use the variable and update the database at the end.

So far, I can't even select...argh!

Here is my code, I tried to simpify everything I could find....

I came up with:

$adCN = ObjCreate ("ADODB.Connection")

$adCN.Open ("DRIVER={SQL Server};SERVER=dba;DATABASE=tc;uid=TC_user;pwd=password;") ;

$adCN.Execute("SELECT notam FROM notamlist ")

$adCN.Close

and I am getting

C:\proxy.au3 (43) : ==> Unable to parse line.:

which is the adcn.execute line

Help please!!!!! Thanks!

I am new to AutoIt but have done some work with a MS-SQL 2000 database.

Here is a sample of some code to get you started.

Connection String
"Provider='sqloledb';Data Source='ServerName';Initial Catalog='DatabaseName';" _
"User ID='sa';Password='password';"

Selection String
$sqlString = "select c.Name, c.ContractID from TEBSchemes..Contracts where RaisedGroup=" & $gGroup
$sqlString &= "  order by Name"
$qryCID = _SQLQuery($oDBid, $sqlString)
While not @error                                   ; retrieve all rows
  If Not $qryCID.EOF Then
      $s_RowValues = StringStripWS($qryCID.Fields(0).Value,3)
      $contractID = StringStripWS($qryCID.Fields(1).Value,3)
      GUICtrlSetData($Label2, $s_RowValues)
      RaiseContract($contractID)
      GUICtrlSetData($lbRaised,$s_RowValues)
      $qryCID.MoveNext
    Else
      SetError(1)
    EndIf
WEnd
$qryCID.Close

One problem (still trying to figure out if it is a bug or I am screwing up! ;) ) I have found is that when a value is returned, it is returned as a zero. I now convert the value to a string in the sql statement and it seems to work Ok!

Cheers

Dougie

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...