i am trying to connect to an MS Access database but i am new to C#. I have looked at, amongst others, Paladin's response to dark omen about connecting to a database and since i have connected to a database before in Visual Basic most of it makes sense to me.

However i do not understand the argument list for the connection string of the SqlConnection object's SqlConnection constructor. On various info sources the arg list for the constructor seems to differ slightly so i assume that some arguments are optional. can someone please tell me what the bare minimum of arguments are for connecting to an MS Access database on a local pc and what each argument means?

Recommended Answers

please follow following link
http://www.codeproject.com/cs/database/linkAccessInCSharp.asp

or write following code

using System;
using System.Data;
using System.Data.OleDb;

public class Test{
    public static void Main()
    {
    string source = "Provider=Microsoft.JET.OLEDB.4.0;" + "data     source=""C:\\Winnt\\Profiles\\Administrator\\Personal\\db2.mdb
    string command="SELECT Name, Assets FROM Bank_customer_data";
    OleDbCommand mCommand = new OleDbCommand(); 
    OleDbConnection mConnection=new OleDbConnection(source);
    mConnection.Open(); …
Jump to Post

All 5 Replies

please follow following link
http://www.codeproject.com/cs/database/linkAccessInCSharp.asp

or write following code

using System;
using System.Data;
using System.Data.OleDb;

public class Test{
    public static void Main()
    {
    string source = "Provider=Microsoft.JET.OLEDB.4.0;" + "data     source=""C:\\Winnt\\Profiles\\Administrator\\Personal\\db2.mdb
    string command="SELECT Name, Assets FROM Bank_customer_data";
    OleDbCommand mCommand = new OleDbCommand(); 
    OleDbConnection mConnection=new OleDbConnection(source);
    mConnection.Open();
    mCommand.ActiveConnection=mConnection; 
    mCommand.CommandText=command;
    OleDbDataReader mReader;
    mCommand.Execute(out mReader); 
    // Use Read to  read data line by line.
    while (mReader.Read()) 
        { //The data is extracted with the methods GetString and GetInt32
        Console.WriteLine(mReader.GetString(0) + ":" + mReader.GetInt32(1));
        }
    // Close the Reader when done. 
    mReader.Close();
    // Close the connection when done. 
    mConnection.Close(); 
    }
}

how to store data from sql to msAccess using C#

plz tell me anybody how to store data from sql to msAccess using C#

plz tell me tell me tell me how to store data from sql to msAccess using C#

Be a part of the DaniWeb community

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