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