Jump to content

VB to AU3


Recommended Posts

Sub Main()

Dim cn as New ADODB.Connection

Dim rs as New ADODB.Recordset

'Open the connection

cn.Open "DSN=<MyDataSourceName>;" & _

"UID=<MyUsername>;" & _

"PWD=<MyPassword>;" & _

"Database=<MyDatabaseName>"

'Clear the table

cn.Execute "DELETE FROM vbtest;"

'For updateable recordsets we would typically open a Dynamic recordset.

'Forward Only recordsets are much faster but can only scroll forward and

'are read only. Snapshot recordsets are read only, but scroll in both

'directions.

rs.Open "SELECT id, data, accessed FROM vbtest", cn, adOpenDynamic, adLockOptimistic

'Loop though the recordset and print the results

'We will also update the accessed column, but this time access it through

'the Fields collection. ISO-8601 formatted dates/times are the safest IMHO.

While Not rs.EOF

Debug.Print rs!id & ": " & rs!data

rs.Fields("accessed") = Format(Now, "yyyy-MM-dd hh:mm:ss")

rs.Update

rs.MoveNext

Wend

'Add a new record to the recordset

rs.AddNew

rs!id = 76

rs!data = 'More random data'

rs!accessed = Format(Now, "yyyy-MM-dd hh:mm:ss")

rs.Update

'Insert a new record into the table

cn.Execute "INSERT INTO vbtest (id, data) VALUES (23, 'Some random data');"

'Refresh the recordset to get that last record...

rs.Requery

'Get the record count

rs.MoveLast

rs.MoveFirst

MsgBox rs.RecordCount & " Records are in the recordset!"

'Cleanup

If rs.State <> adStateClosed Then rs.Close

Set rs = Nothing

If cn.State <> adStateClosed Then cn.Close

Set cn = Nothing

End Sub

Link to comment
Share on other sites

  • Developers

You forgot to specify the question/issue you have or is your expectation that somebody will do the whole conversion for you ?

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Search forum for examples using ADODB and make this simple conversion according to them.

Tryed... But all the time geting same error

http://www.autoitscript.com/forum/index.ph...470&hl=odbc

maybe soone can convert to working script.. :/ im getting despred.. Have a grat project but cant acomplishe it because of stupid PostGres ODBC

Pleas help me... :/

Link to comment
Share on other sites

Thanks all for help or ideas or just saying "make it by your self"

Done

PostGres

Func postgres_query($query)
$oConn = ObjCreate("ADODB.Connection")
$oRS = ObjCreate("ADODB.Recordset")
$cmd = ObjCreate("ADODB.Command")

$line2 =    "DRIVER={PostgreSQL ANSI};DATABASE=Incoming_rates;" & _
            "SERVER=localhost;PORT=5432;Uid=odbc_usr;" & _
            "Pwd=odbc_usr;" & _ 
            "A0=0;A1=6.4;A2=0;A3=0;A4=0;A5=0;A6=;A7=100;A8=4096;A9=0;" & _
            "B0=254;B1=8190;B2=0;B3=0;B4=1;B5=1;B6=0;B7=1;B8=0;B9=1;C0=0;C1=0;C2=dd_"

$oConn.Open ($line2)
$oConn.execute ($query)
$oConn.Close

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