Odd exception. Your code shouldn't even compile. Remember, C# is case sensitive,
so OleDB and OleDb are not the same identifier. Also, your connection string
needs to be closed with a closing paren and semi-colon. The code below should
open a connection for you, provided you are running a Windows application. Things
are a bit different with ASP.NET Web applications, because you need to take user
authentication and authorization into account, usually by impersonating your NT
authentication account.
using System;
using System.Data;
using System.Data.OleDb;
namespace ConsoleApplication1
{
class Class1
{
static void Main(string[] args)
{
OleDbConnection thisConnection = new OleDbConnection(
@"Provider=Microsoft.Jet.OLEDB.4.0;" +
@"Data Source=c:\Northwind.MDB");
// Open connection
thisConnection.Open();
}
}
}
HTH,
Bob
|