Click to See Complete Forum and Search --> : opening an access db using Vc#


Saeed
July 28th, 2005, 08:52 PM
I downloaded teh sample code included for db example from msdn but it was out of date .Phewww
I created a dummy Access db with atable that has a few records and columns to populate my GridControl .
However for some reason (whether its a param missing or access security) am unable to connect to the database. Has anyone done anything like this that can help ? cheers

System.Data.OleDb.OleDbConnection conn = new
System.Data.OleDb.OleDbConnection();
conn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data source= D:\Mooo.mdb";
try
{
conn.Open();
// Insert code to process data.
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
MessageBox.Show("Failed to connect to data source");
}
finally
{
conn.Close();
this.Close();
}

Thanks in Advance.

Saeed
July 28th, 2005, 09:50 PM
oK GOT IT.
THE MDAC WAS OF VERSION 2.5 ..

Andy Tacker
July 29th, 2005, 01:45 AM
moved to C# forum...

Saeed, you are "Member+". so, please double check the forum you are posting to. that's not too hard to do. posting C# post in C++.NET is not quite good...

Saeed
July 29th, 2005, 03:23 AM
that was not intentional ...
guess eyes get tired now and then
ignore this post please