Click here to Skip to main content
14,984,032 members
Please Sign up or sign in to vote.
1.00/5 (1 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 21:23pm

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[^]
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, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900