I use ODBC data source to connect vb.net application to MS ACCESS database.When I have to install it in my clients PC,I have to manually make ODBC connection
from(Control Panel ->Administrative Tools->Data source(ODBC)).
Now what I want to do is,include odbc connection string in vb.net code itself so that I dont have to manually create odbc connection in clients PC.Is it possible to do so??
If no,then is there any other alternative?
Thanks in advance.

Not 100% if this answers your question but I wrote this code for a car game in college.

Pass the sql command to the function and it executes on the database it is set up to access.
Hope it helps.

    Public Sub sqlCmd(ByVal SQLText As String)
        Dim retVal As Integer = 0

        Dim myConnection As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=CarGame.accdb")
        myConnection.Open()
        Dim myCommand As OleDbCommand = myConnection.CreateCommand()
        Dim myTrans As OleDbTransaction

        ' Start a local transaction 
        myTrans = myConnection.BeginTransaction(IsolationLevel.ReadCommitted)
        ' Assign transaction object for a pending local transaction  
        myCommand.Connection = myConnection
        myCommand.Transaction = myTrans
        Try
            myCommand.CommandText = SQLText
            retVal = myCommand.ExecuteNonQuery()
            myTrans.Commit()
        Catch er As Exception
            MessageBox.Show(er.Message)
            myTrans.Rollback()
        Finally
            myConnection.Close()
        End Try
        'This sub is a generic routine that allows SQL commands to be sent
    End Sub

Make sure the Database is in the resources folder before exporting as an installable program.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.