Results 1 to 2 of 2

Thread: How to connect

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2001
    Posts
    9

    How to connect

    Hi
    can u tell me how to connect :
    1)Access dat base with vb.net via Ado
    2)Mysql datbase " " " " " " " " "
    3)Oracle database

  2. #2
    New Member Varadero's Avatar
    Join Date
    Aug 2002
    Posts
    7
    This is how I connect to an Access-database, i don't think it will be much different from connecting to another database.

    '-------------------------------------------------------------------------------
    'Usage : Constructor
    'Parameters : -
    'Return :
    'Authors : Bart Schelkens
    'Reviews :
    'Date Creation: 13/08/2002
    'Modifications:
    ' nr : date : reason
    'Errorhandling:
    'Remarks : A connection to the database and a data adapter are initialized
    '-------------------------------------------------------------------------------
    Public Sub New()
    Try
    'strCONNECTION is the connectionstring for your database
    ' in my case it looks like this => "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Development\MyDatabase.mdb"
    mconDB = New OleDbConnection(strCONNECTION)
    mconDB.Open()
    mdtaDataAdapter = New OleDbDataAdapter()
    Catch e As Exception
    Throw (e)
    End Try
    End Sub

    And then i use this to fill my dataset :

    '-------------------------------------------------------------------------------
    'Usage : Fetches a typed Artists dataset list of rows
    'Parameters : -
    'Return :
    ' A typed Artists Dataset
    'Authors : Bart Schelkens
    'Reviews :
    'Date Creation: 13/08/2002
    'Modifications:
    ' nr : date : reason
    'Errorhandling:
    'Remarks :
    '-------------------------------------------------------------------------------
    Public Function GetList() As DiscoBar.DataSets.DSArtists

    Return FillDataSet("SELECT * FROM Artists ORDER BY Artist")

    End Function


    '-------------------------------------------------------------------------------
    'Usage : Fetches a typed Artists dataset
    'Parameters :
    ' ByVal vstrCommandText as string => The source sql statement used to fetch the dataset
    'Return :
    ' A typed Artists dataset
    'Authors : Bart Schelkens
    'Reviews :
    'Date Creation: 13/08/2002
    'Modifications:
    ' nr : date : reason
    'Errorhandling:
    'Remarks :
    '-------------------------------------------------------------------------------
    Private Function FillDataSet(ByVal vstrCommandText As String) As DiscoBar.DataSets.DSArtists
    Dim dsData As DiscoBar.DataSets.DSArtists = New DiscoBar.DataSets.DSArtists()
    Dim cmdCommand As OleDbCommand = New OleDbCommand()

    cmdCommand.Connection = mconDB
    cmdCommand.CommandType = CommandType.Text
    cmdCommand.CommandText = vstrCommandText

    mdtaDataAdapter.SelectCommand = cmdCommand
    mdtaDataAdapter.Fill(dsData, "Artists")

    Return dsData
    End Function

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width