Click here to Skip to main content
14,448,994 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hi All,
I m developing C# windows base application where name space I used

using System;
using System.Data.OleDb;
 class basecon
        public static string inv = "";
        public string connection()
            string p;
            p = Application.StartupPath.ToString() + @"\conn.ini"; 

private void grid()
            DataGridViewTextBoxColumn dgvCol = new DataGridViewTextBoxColumn();
            con.ConnectionString = Microsoft.VisualBasic.Strings.Trim(obj.connection().ToString());

// please help me how to write oleDb connection path


[edit]Code block added - OriginalGriff[/edit]
Updated 25-Jul-11 22:23pm
Rate this:
Please Sign up or sign in to vote.

Solution 1

Put your mdb file in bin/Debug folder

then access it like

string con=@"Provider=Microsoft.Jet.OleDB.4.0;DataSource=abc.mdb";

If you have format other then mdb then Check this[^]
Rate this:
Please Sign up or sign in to vote.

Solution 2

The simplest way is to start by looking at your database in the Server Explorer pane.
Highlight the database you are interested in, and look at the Properties pane - the connection string will be shown there.
Copy that, and paste it into a configuration string in the Settings.settings section of the properties for you project. This will allow you to change it easily if you move your database later, or change machines.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100