WebSam DB COnnector(tm) 2.0

WebSam DB COnnector allows you to make connection to any database without headach.

It supports direct connection to Access97/2000, MSSQL, Oracle, and ODBC/DSN connection. You can set customnised connection successful/fail message, or you can use its default messages.

It is simple to use, and return you an open database connection for you to manipulate data of the connection.

In your Visual Studio, you should make project reference to "WebSam DB Connector".


Sample Code:


Access Connection
======================================================================
    Dim WithEvents x As Samdb.dbconnection 'declare object with events
    Dim rs As New ADODB.Recordset
    
    On Error Resume Next ' this is to bypass error occurs in x.dbconn.state during first run

    Set x = New Samdb.dbconnection

    with x
      .DBaseType = Access2000        'set database type
      .Path = App.Path & "\db1.mdb"  'set MsAccess file path (change if not in the same location)
    End With    

    If x.dbconn.State = adStateOpen Then  ' check if x.dbconn is open
        x.dbconn.Close                    ' close it if it is open
    End If
    x.dbconnect     			  ' connect to database
    
    With rs
        .CursorLocation = adUseClient
        .LockType = adLockOptimistic
        .CursorType = adOpenDynamic
        .Source = "select * from members"
        .ActiveConnection = x.dbconn
        .Open
    End With
    
    If Not rs.EOF Then          ' populate DataGrid if database is not empty
        DataGrid1.ClearFields   ' clear Datagrid before populate
        Set DataGrid1.DataSource = rs
    Else
        MsgBox "Database Empty!", vbOKOnly + vbInformation, "Empty Database"
    End If

    Set x = Nothing              ' drop object




MS SQL Connection
======================================================================
    Dim WithEvents x As Samdb.dbconnection 'declare object with events
    Dim rs As New ADODB.Recordset
	
    With x
      .DatabaseType = MSSQL
      .Path = "your SQL server name, eg. server1"
      .InitCatalog = "pubs"
      .LoginID = "sa"
      .LoginPwd = "123456"
    End With



Oracle Connection
======================================================================
    Dim WithEvents x As Samdb.dbconnection 'declare object with events
    Dim rs As New ADODB.Recordset

    With x
      .DatabaseType = Oracle
      .Path = "oracle_service.oracle_servername"
      .LoginID = "scott"
      .LoginPwd = "tiger"
    End With



DSN Connection
======================================================================
    Dim WithEvents x As Samdb.dbconnection 'declare object with events
    Dim rs As New ADODB.Recordset

    With x
      .DatabaseType = DSNConnect
      .Path = "DSN_name"
      .LoginID = "login_if_needed"
      .LoginPwd = "password_if_needed"
    End With


Event Handling on Connect and on Error
======================================================================


Private Sub x_OnConnect()   ' activate when x.dbconn is connected

End Sub


Private Sub x_OnError()     ' activate when x.dbconn error occurs

End Sub






***********************************************************************
* What's New 
***********************************************************************

Verion 1.1
===========
(30/01/2002)
1. Allow you to disable showing message each time when you connect



Version 2.0
===========
(1/5/2002)
1. Customisable Event Handling
2. Bug fixed


************************************************************************
For further technical questions, please email 

1. samy_liu@hotmail.com
2. samy_liu@sinaman.com
