Announcement

Collapse
No announcement yet.

PwrDev - com interfaces

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • PwrDev - com interfaces

    New features are added to PwrDev regurarly.

    New is the use of com objects.
    The upcomming .NET database 'com wrapper' is a good example to make late bound calls strong typed by using a com object:
    Code:
     
        Local T     As String 
        Local sSQL  As String 
        Local dr    As VD_CLR_CommonDB_IDataReader 
        Local v     As Variant 
         
        ' Create a datareader object 
        dr = Class "VD_CLR_CommonDB_DataReader" 
     
        ' Enable debugging via OutputDebugString() API, for diagnostic purposes only. 
        dr.EnableDebug = 1 
         
        ' Establish a connection. 
        If dr.Connection.Open( _ 
              Empty _ 
            , "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=BIBLIO.MDB;Persist Security Info=False" ) Then 
         
            ' Obtain tablenames 
            T = dr.GetTableNames() 
            If Len( T ) = 0 Then T = dr.LastException.GetLastErrorMessage     
            VD_Debug_Print "Tables:" & $CrLf & T 
     
            ' Prepare query and parameters, parameters how it should be done(!) 
            sSQL = "SELECT TOP 10 * FROM [Authors] WHERE AU_ID < @ID ORDER BY [Author]" 
            dr.Parameters.Clear() 
            dr.Parameters.Add("ID", 100, Empty ) 
     
            ' Use the query to create a reader object, success implies at least one record was found. 
            If dr.Reader.Open( sSQL ) Then 
     
                ' Enum fieldnames. 
                T = "'" & dr.Reader.Fields.Names() & "'"             
                VD_Debug_Print "Fields: " & $CrLf & T             
     
                ' Enum records, this is a forward-only recordset. 
                ' If the read() returns false, the end of the recordset is reached. 
                Do 
                 
                    ' Obtain data via a variant and/or wrapper methods to obtain nr's and strings as string. 
                    dr.Reader.GetFieldData( 0, v ) 
                    VD_Debug_Print Format$( Variant#( v ), "0000" ) & ", " & dr.Reader.GetFieldStr( 1 ) 
                     
                Loop Until dr.Reader.Read() = 0 
     
                VD_Debug_Print dr.LastException.GetLastErrorMessage     
                 
                dr.Reader.Close() 
     
            End If 
     
        Else 
         
            T = dr.LastException.GetLastErrorMessage     
            MsgBox T 
     
        End If 
     
        ' Closing each object in the DataReader class is usually pointless, terminating the DataReader will also close all objects. 
        dr.Connection.Close() 
        dr = Nothing
    Note code like: dr.Connection
    Connection is really an object inside dr.

    Evt. see also:
    http://www.hellobasic.com/cgi-bin/fo...798456;start=0
    hellobasic

  • #2
    This specific .NET database support is now available, PwrDev users please visit the forum for details.

    This .NET assembly is executed from memory, looks like static linking this way.

    The assembly use the DbProviderFactory object found in System.Data.Common.
    This means it can support any known driver ADO.NET can use.
    Like Odbc, OleDb and SQLServer for example.
    hellobasic

    Comment


    • #3
      Added:

      Support to obtain schema information from a database through it's connection.

      --

      If you need to know more how to deal with .NET using PowerBASIC and PwrDev, let me know.

      Having ADO.NET's database support is now a click away.
      Calling (ASP.NET)webservices is very easy.
      Using .NET winform controls is also easy, just create an assembly having a usercontrol with your desired controls.
      Just put the namespace and assemblyname in the PwrDev placeholder and you are up for running..
      Embed assemblies directly into the executable and call them from memory or resource.

      And since PowerBASIC can now do classes, it's fairly 1:1 programming.
      Create an oop style assembly (dll) and write a com wrapper.

      Note that the assemblies don't need to be registered, this also applies to an evt. com wrapper.
      Just compile and use!
      hellobasic

      Comment


      • #4
        A small topic how to embed an assembly

        http://www.hellobasic.com/cgi-bin/fo...161559;start=0
        hellobasic

        Comment

        Working...
        X