aXend's COMLIB
Posted: Wed Mar 02, 2005 2:41 pm
Does anyone happen to know where aXend went? I'd like to get a copy of his COMLIB done with the new tailbite so that it works with 3.93..
Thanks guys!
Thanks guys!
Hmm, just downloaded, no documentation with the link provided.aXend wrote:COMLIB is a library to work with COM from PureBasic. You can find the previous version - including documentation - at http://home.planet.nl/~aXend/purebasic/COMLIB_demo.zip or at PureArea.Net. You can find discussions about it elsewhere on this forum.
Code: Select all
; --------------------------------------------------------------------------------------------------------
; This is a demo program to demonstrate the use of COM from PureBasic.
;
; The zip file contains 5 items:
; - COMLIB (library file, put it in the Userlibraries directory)
; - Variant_inc.res (resident file with definitions for VARIANTS, put it in the Residents directory)
; - Variant_inc.pb (the pb version, use as Includefile)
; - ADODB.pb (the Interface definitions for ADODB, use as Includefile)
; - test_ado.pb (this demo program)
;
; COMLIB is a small library that contains 4 procedures:
;
; CreateObject(ProgID.s) - creates an object from a ProgID, just like VB does
; ReleaseObject(Object.l) - release the object
; Uni2Ansi(Unicode.l) - converts a Unicode string to Ansi
; Ansi2Uni(Ansistr.s) - converts an Ansi string to Unicode
;
; This demo program demonstrates the functionality of COMLIB with ADODB.
; ADODB is a COM object to access databases
;
; Created by aXend, 2004.
; For questions: use the forum or mail to aXend@planet.nl
;
; --------------------------------------------------------------------------------------------------------
IncludeFile "ADODB.pb" ; Definitions for all the Enumerations and Interfaces
;IncludeFile "Variant_inc.pb" ; Definitions for VARIANTS (not used here, I use the resident version)
Global sSQL.s
; Create a Connection object using the _Connection Interface and the CreateObject procedure from COMLIB
oDatabase._Connection = CreateObject("ADODB.Connection")
; Define the connectionstring (may be you have to change the path settings)
conn.s ="PROVIDER = MICROSOFT.JET.OLEDB.4.0; DATA SOURCE = 'test_ado.mdb'"
; Open the database
If oDatabase\Open(Ansi2Uni(conn),#Null,#Null,-1) = #S_OK
; I copied one tabel from the Dutch version of Northwind.mdb
sSQL = "SELECT * FROM CUSTOMERS"
; Execute the query and create a Recordset object
If oDatabase\Execute(Ansi2Uni(sSQL),@affected.VARIANT,-1,@oRecords._Recordset) = #S_OK
; Get the EOF property
oRecords\get_EOF(@EOF.VARIANT)
; If there are records in the table then continue
If EOF\value = #VARIANT_FALSE
; Get the Fields object
If oRecords\get_Fields(@oFields.Fields) = #S_OK
; Get the number of fields
oFields\get_Count(@count.l)
Debug "Number of fields is "+Str(count)
; Loop through the fields. I use the index mode here, but you can also access a field by name.
For i = 0 To count-1
; Definitions for each field, you have to do this or else it gets stuck
item.VARIANT\vt = #VT_I4 ; this is the VARIANT type for the index
item\value = i ; this is the index
*item.pToVariant = item ; this cuts the VARIANT in 4 LONG values
; Get a Field object by passing the 4 LONG values
If oFields\get_Item(*item\a,*item\b,*item\c,*item\d,@oField.Field) = #S_OK
oField\get_Value(@Field.VARIANT)
oField\get_Name(@Name.l)
If Field\vt <> #VT_BSTR
Debug Uni2Ansi(Name) + ": " + Str(Field\value)
Else
Debug Uni2Ansi(Name) + ": " + Uni2Ansi(Field\bstrVal)
EndIf
; Release the Field object
oField\Release()
EndIf
Next
; Release the Fields object
oFields\Release()
EndIf
EndIf
; Release the Recordset object
oRecords\Release()
EndIf
; Close the Connection
oDatabase\Close()
EndIf
; Release the Connection object
ReleaseObject(oDatabase)
End
this link if still ok for a good ADO example (using COMLIB).blackborg wrote:the Ansi2Uni command clashes with Droopy's LIB.. but what I really need is a help file or some working ADO code.. any word on an official Fred COM or ADO Lib?