Problems connecting to Access database

lerenard1968

New Member
Hi all, so I'm just learning ASP.NET, and I'm trying to get a basic database to web page connection set up. I've found a few nice tutorials, and I got things working without much of a problem. In that case I was using the OleDbConnection class to connect to an Access database, so my code looked something like this(C#):<BR><BR>OleDbConnection connection;<BR>String connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;"<BR> + "Data Source=C:\inetpub\wwwroot\access\database.MDB";<BR><BR>and so on. So then I found a site that said I should be using the SqlConnection class instead, because it was faster. Well, I figured I'd try that, but then I ran into problems with the connection. I'm almost positive it's the connection string, because I really don't know what the format should be; most examples just skip right over it. Here's what I have now:<BR><BR>SqlConnection sqlConnection;<BR>String sqlConnectionString = "server=localhost;database=database;Trusted_Connect ion=yes";<BR><BR>It's trying to connect to a database that's sitting in C:inetpubwwwrootaccessdatabase.MDB, which is the same directory the code is in.<BR><BR><BR>Ok, so my first question is, which class should I be using to connect? Is the performance thing a big issue? Will it matter that I will probably be connecting to Oracle when I'm using the code in a production environment? Second, what should my connection string look like? I've tried a lot of different things, but nothing seems to work.<BR><BR><BR>Thanks,<BR><BR>John GerstenslagerYou can only use SQL connection when connecting to Sql Server 7 or 2000. And you truly only get the best speed from sql server 2000 because of the excellent xml support. For Access you should use the oledb connection. Microsoft recently released an oracle managed provider which you should look into for connection to oracle. <BR><BR>hth<BR>JamesAhh, it all makes sense. Thanks so much.<BR><BR>JohnHi John,<BR><BR>There's an excellent tutorial on SQL and OleDb classes at:<BR><BR>http://www.4guysfromrolla.com/webtech/chapters/ASPNET/ch06.shtml<BR><BR>JON<BR>
 
Back
Top