Jump to content
Sign in to follow this  
Ritch

SQL

Recommended Posts

Ritch

DB name: login

Table Name: login

Colun names: login, pass, char, block

$conn = ObjCreate( "ADODB.Connection" )
$DSN = "DRIVER={SQL Server};SERVER=XXX\SQLEXPRESS;DATABASE=login;UID=sa;PWD=XXX;"
$conn.Open($DSN)
$rs = ObjCreate( "ADODB.RecordSet" )
$rs.Open( "SELECT * FROM login", $conn )
MsgBox(0, "AutoIT-SQL Result", "Value = " & $rs.Fields( "Login" ).Value )
$conn.close

This code below funcima correctly. It returns me the first value from the column " login".

to put I need that it returns me the value from the column "pass" in one determined line of the column " login".

Example:

login | pass | char | block

________________________

toao | 102030 | mage | 0

tiao | 101112 | tief | 0

i need put tiao and receive value 101112 how I would make?

Share this post


Link to post
Share on other sites
Zedna

Something like this

$output = ''

$conn = ObjCreate( "ADODB.Connection" )
$DSN = "DRIVER={SQL Server};SERVER=XXX\SQLEXPRESS;DATABASE=login;UID=sa;PWD=XXX;"
$conn.Open($DSN)
$rs = ObjCreate( "ADODB.RecordSet" )
$rs.Open( "SELECT * FROM login", $conn )
If $RS.RecordCount Then
 While Not $RS.EOF
    $output += $RS.Fields(0).Value & '|' & $RS.Fields(1).Value & '|' & $RS.Fields(2).Value & '|' & $RS.Fields(3).Value & @CRLF ; value of 4 columns on this line
    $RS.MoveNext
 WEnd
EndIf
MsgBox(0, "AutoIT-SQL Result", "Result" & @CRLF & $output )
$conn.close

Next time try to search forum for examples first.

Share this post


Link to post
Share on other sites
Ritch

not work!

This returning the value " 0" to put this value does not exist.

where I place the value of the line that is pra to be looked for.

I edited this line below in accordance with my table, this correct one?

$output += $RS.Fields("login").Value & '|' & $RS.Fields("pass").Value & '|' & $RS.Fields("char").Value & '|' & $RS.Fields("block").Value & @CRLF ; value of 4 columns on this line

my idea is the name to serve as ID!

e this that I am making is a system of login to have access the functions of the macro.

Edited by Ritch

Share this post


Link to post
Share on other sites
PsaltyDS

I edited this line below in accordance with my table, this correct one?

$output += $RS.Fields("login").Value & '|' & $RS.Fields("pass").Value & '|' & $RS.Fields("char").Value & '|' & $RS.Fields("block").Value & @CRLF ; value of 4 columns on this line

my idea is the name to serve as ID!

e this that I am making is a system of login to have access the functions of the macro.

I think you want the .Item within the .Fields collection, i.e. $RS.Fields.Item("login").Value

:)

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
Ritch

$output = ''

$conn = ObjCreate( "ADODB.Connection" )
$DSN = "DRIVER={SQL Server};SERVER=XXX\SQLEXPRESS;DATABASE=login;UID=sa;PWD=XXX;"
$conn.Open($DSN)
$rs = ObjCreate( "ADODB.RecordSet" )
$rs.Open( "SELECT * FROM login", $conn )
If $RS.RecordCount Then
 While Not $RS.EOF
   $output += $RS.Fields.item("login").Value & '|' & $RS.Fields.item("pass").Value & '|' & $RS.Fields.item("char").Value & '|' & $RS.Fields.item("block").Value & @CRLF ; value of 4 columns on this line
   $RS.MoveNext
 WEnd
EndIf
MsgBox(0, "AutoIT-SQL Result", "Result" & @CRLF & $output )
$conn.close

show-me result = 0

correct value is:

tiao | 101112 | tief | 0

Share this post


Link to post
Share on other sites
PsaltyDS

$output = ''

$conn = ObjCreate( "ADODB.Connection" )
$DSN = "DRIVER={SQL Server};SERVER=XXX\SQLEXPRESS;DATABASE=login;UID=sa;PWD=XXX;"
$conn.Open($DSN)
$rs = ObjCreate( "ADODB.RecordSet" )
$rs.Open( "SELECT * FROM login", $conn )
If $RS.RecordCount Then
 While Not $RS.EOF
   $output += $RS.Fields.item("login").Value & '|' & $RS.Fields.item("pass").Value & '|' & $RS.Fields.item("char").Value & '|' & $RS.Fields.item("block").Value & @CRLF ; value of 4 columns on this line
   $RS.MoveNext
 WEnd
EndIf
MsgBox(0, "AutoIT-SQL Result", "Result" & @CRLF & $output )
$conn.close

show-me result = 0

correct value is:

tiao | 101112 | tief | 0

Oh, now that's just dumb! (Not just you, me too for missing it!)

$output &= $RS.Fields...

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
Ritch

tanks men =P

show all rows =P

^^

i need show any row tiao oO

Share this post


Link to post
Share on other sites
PsaltyDS

how to show any line tiao?

Shouldn't you have included that in your query?

; Note "FROM login" is the table name, and "WHERE login" is a field name
$rs.Open("SELECT * FROM login WHERE login='tiao'", $conn)

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
Ritch

$output = ''

$conn = ObjCreate( "ADODB.Connection" )
$DSN = "DRIVER={SQL Server};SERVER=LIS\SQLEXPRESS;DATABASE=login;UID=sa;PWD=102031;"
$conn.Open($DSN)
$rs = ObjCreate( "ADODB.RecordSet" )
$rs.Open("SELECT * FROM login WHERE Login='tiao'", $conn)
If $RS.RecordCount Then
 While Not $RS.EOF
   $output &= $RS.Fields.Item("Login").Value & '|' & $RS.Fields.Item("pass").Value & '|' & $RS.Fields.Item("char").Value & '|' & $RS.Fields.Item("Block").Value & @CRLF ; value of 4 columns on this line
   $RS.MoveNext
 WEnd
EndIf
MsgBox(0, "AutoIT-SQL Result", "Result" & @CRLF & $output )
$conn.close

error oO

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.