Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem connect to access with ado.net 1

Status
Not open for further replies.

Korach

Programmer
Jun 2, 2003
303
IL
Hi everyone,

I want to build a simple asp.net page that saves the form data into an access database. I opened the database like this:
Code:
this.db = new System.Data.OleDb.OleDbConnection();

this.db.ConnectionString = @"Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Database Password=;Data Source=""Mishmar.mdb"";Password=;Jet OLEDB:Engine Type=5;Jet OLEDB:Global Bulk Transactions=1;Provider=""Microsoft.Jet.OLEDB.4.0"";Jet OLEDB:System database=;Jet OLEDB:SFP=False;Extended Properties=;Mode=Share Deny None;Jet OLEDB:New Database Password=;Jet OLEDB:Create System Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;User ID=Admin;Jet OLEDB:Encrypt Database=False";

db.open();

I copied the connection string from the properties of the connection in the server explorer.
I didn't put any passwords in the access database. I put the access file in system32 folder because it is the only place the program could find it.
When I opened the page, there was an error that said the access file is already opened or I don't have an access to view its data.
When I tried to do this in a c# application without asp, it worked fine!
Is there something diferrent in asp than c# working with ado?

Thanks
 
You might need to reset security permissions to full access on the folder that contains the database file.
 
kor: For testing use this:

'open database...
Dim cmdSelect As OLEDbCommand
Dim dbconn As OleDbConnection = New OleDbConnection( _
"Provider=Microsoft.Jet.OLEDB.4.0; " & _
"Data Source=" & Server.MapPath("fpdb\Sites.mdb;"))
cmdSelect = New OLEDbCommand("SELECT DISTINCT County FROM WebMasterSites", dbconn)
dbconn.Open()
ddCty.DataSource = cmdSelect.ExecuteReader()
ddCty.DataBind()
dbconn.Close()
 
the access file can go anywhere within the scope of your web application... but you need to map the path of your web application in order first it to write or read there..... the asp.net process will not try looking there... it goes directly to system32 directory. D'oh!

use relative paths with Server.MapPath ....

otherwise you have to give the ASP.NET user account on your IIS server read/write NTFS premissions on the Windows/system32 directory... not really recommended!!!!

[afro]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top