[Gambas-user] hConnection = New Connection ( [ DatabaseURL As String ] )

paulwheeler paulwheeler at ...546...
Mon Aug 26 04:47:04 CEST 2013


   This will allow you to open a connection anywhere. All you have to change is
   the "sName" and the .Host entry
   Enjoy!
   paul
   '' Put these at the  beginning of your program on your form named fMain:
   Public $hConn As New Connection
   Public sMyPath As String
   Public sAppPath As String
   '' Your routine to open the connection:
   Public Sub Open_DB()
       ' If you want to see the commands sent to the database then uncomment
   this line:
       ' DB.Debug = True
          Print   "$hConn.Opened   from   fMain   Form  (s/b  F)  =  "  &
   Str($hConn.Opened)    ' For debug purposes only

        sName = "MyDatabaseName.sqlite"
        Print "sName = " & sName             ' For debug purposes only

        With $hConn
            .Type = "sqlite3"         ' Choose DB type for library database
   since users won't know anything
            .Host = "/share/projects/gambas3_proj/horse/
            .Name = sName             ' "MyDatabaseName.sqlite"
        End With

         sTryMessage  =  "OpenConn"       ' I had multiple kinds of catch
   statements. This is for debugging the opening of a connection
        Print "Try to open connection for use"
        Try $hConn.Open
          Print   "$hConn.Opened   from   fMain  Form  (s/b  T)   =  "  &
   Str($hConn.Opened)        ' For debug purposes only
        Print "Connection Host = " &
   $hConn.Host                                     ' For debug purposes only
        Catch
        If sTryMessage = "OpenConn" Then
            If errorMessageHeader = "" Then
                errorMessageHeader = "Could not open DB connection in fMain
   Form Open on "  ' & sName & " On " & sMyPath
                 Print "Connection Open Error in fMain Form Open " & Error.Text
                 Error.Raise(Error.Text & " in  fMain Form Open")
            End If
        Endif
   End

   On 08/25/2013 04:29 PM, Bruce wrote:

What syntax for "DatabaseURL As String"?

I'm trying to create a connection to an SQLite db in a different gambas
project source directory:

        $conn = New
        Connection("/share/projects/gambas3_proj/horse/horseBO/.connection/bome
ta.connection")

(and various other path strings to the connection definition).

All I get is "Malformed URL" error.

?
tia
Bruce


------------------------------------------------------------------------------
Introducing Performance Central, a new site from SourceForge and 
AppDynamics. Performance Central is your source for news, insights, 
analysis and resources for efficient Application Performance Management. 
Visit us today!
[1]http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
_______________________________________________
Gambas-user mailing list
[2]Gambas-user at lists.sourceforge.net
[3]https://lists.sourceforge.net/lists/listinfo/gambas-user

References

   1. http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
   2. mailto:Gambas-user at lists.sourceforge.net
   3. https://lists.sourceforge.net/lists/listinfo/gambas-user



More information about the User mailing list