X-Original-To: pgsql-odbc-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 2CA049DC9A7 for ; Fri, 6 Jan 2006 00:16:15 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 86211-10 for ; Fri, 6 Jan 2006 00:16:13 -0400 (AST) Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id EFDAE9DC9D6 for ; Fri, 6 Jan 2006 00:16:12 -0400 (AST) Received: from a.relay.invitel.net (a.relay.invitel.net [62.77.203.3]) by svr4.postgresql.org (Postfix) with ESMTP id 038A95AF028 for ; Fri, 6 Jan 2006 04:16:11 +0000 (GMT) Received: from mail.invitel.hu (mail.vnet.hu [213.163.59.4]) by a.relay.invitel.net (Invitel Core SMTP Transmitter) with ESMTP id 59372110C34 for ; Fri, 6 Jan 2006 05:16:07 +0100 (CET) Received: from [192.168.1.107] ([82.131.165.207]) by mail.invitel.hu (Invitel Messaging Server) with ESMTPA id <0ISN009WPL4R67A0@invitel.hu> for pgsql-odbc@postgresql.org; Fri, 06 Jan 2006 05:14:57 +0100 (CET) Date: Fri, 06 Jan 2006 05:12:26 +0100 From: linuxgps Subject: VBA 6 crashes with WIN2K, Postgres 8.1, why ? which dll ?? To: pgsql-odbc@postgresql.org Message-id: <43BDEE2A.1060809@invitel.hu> MIME-version: 1.0 Content-type: text/plain; charset=ISO-8859-1; format=flowed Content-transfer-encoding: 7BIT X-Accept-Language: en-us, en User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0 required=5 tests=[none] X-Spam-Score: 0 X-Spam-Level: X-Archive-Number: 200601/32 X-Sequence-Number: 6847 Hi all, I'm a beginner to MS Windows. I began to to test VBA 6.0(SP6) with Postgresql 8.1 -with odbc- on WIN2K(SP4). For the test (accessing postgres db thru visual basic) I use the code, given by the distro (psqlODBC HOWTO- Visual Basic). The first problem I've encounted that the code in the given test snippet is not full functioning: "rs.Refresh" doesn't implemented ? I use in the "Project Preferences" "Microsoft ActiveXData Objects 2.1 library (msado21.tlb) I've installed some other MS stuff on the machine, and now the Postgres database call makes a memory exception and crashes. Q 1.: Is this general, or some libraries are wrong on my system ? Q 2.: Which MS tools are to control/update the msado-libraries Q.3.: Which msado or similars are necessary to connect with visual basic to postgres ? thank you in advance testuser vba ----------------- Sub Main() Dim cn as New ADODB.Connection Dim rs as New ADODB.Recordset 'Open the connection cn.Open "DSN=;" & _ "UID=;" & _ "PWD=;" & _ "Database=" '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 FROM vbtest", cn, adOpenDynamic '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.Refresh '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