Jump to content

SQL


Ritch
 Share

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

$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

Link to comment
Share on other sites

$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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

$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

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