Jump to content
Sign in to follow this  

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>;" & _


'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


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")




'Add a new record to the recordset


rs!id = 76

rs!data = 'More random data'

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


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


'Get the record count



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


If rs.State <> adStateClosed Then rs.Close

Set rs = Nothing

If cn.State <> adStateClosed Then cn.Close

Set cn = Nothing

End Sub

Share this post

Link to post
Share on other sites

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


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.

Share this post

Link to post
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


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

Share this post

Link to post
Share on other sites

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



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;" & _

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


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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...