View Full Version : Database Connection strings in web.config
You can find the full server path in the Account Information of your control panel.
DiscountASP.NET
http://www.DiscountASP.NET
infinitedes
09-11-2004, 12:07 PM
I like to use web.config files for database connection strings
However I'm not sure how to access my database on discountasp:
Provider=Microsoft.Jet.OLEDB.4.0;Data source=D:\Inetpub\WWWroot\03Fall\hallo\database\Mu sicStore.mdb;
</font id="limegreen">
worked when my site was hosted on another server but I'm not sure
</font id="brown">
Owen
infinitedes
09-15-2004, 11:35 AM
So let me get this straight the path would be like
e:\web\infinitedes\htdocs\_database\MusicStore.mdb
Owen
bruce
09-15-2004, 12:38 PM
if your database is in the _database directory.
[b]quote:Originally posted by infinitedes
So let me get this straight the path would be like
e:\web\infinitedes\htdocs\_database\MusicStore.mdb
Owen
</blockquote id="quote"></font id="quote">
B.
DiscountASP.NET
http://www.DiscountASP.NET
bruce
09-24-2004, 06:27 AM
Add this line
myConn.open
after this
myConn = New OleDbConnection (DSN)
[b]quote:Originally posted by infinitedes
I got an error when I tried using the physical path as suggested:
Here is the code to my configuration file to connect to the database
[quote]
<configuration>
<!--applicationspecificsettings--><appSettings>
<addkey="strConnection"value="Provider=Microsoft.Jet.OLEDB.4.0;Datasource=
"e:\web\infinitedes\htdocs\_database\MusicStore.mdb ;"/>
</appSettings>
</configuration>
</CODE>
Here is the code that generates the error
[quote]
DimDSNasstring=ConfigurationSettings.AppSetting("strConnection")
DimmyConnAsOleDbConnection
myConn=NewOleDbConnection(DSN)
DimselectCMDAsOleDbCommand=NewOleDbCommand(strSQL, myConn)
selectCMD.CommandTimeout=30
DimasinDAAsOleDbDataAdapter=NewOleDbDataAdapter
asinDA.SelectCommand=selectCMD
DimasinDSAsDataSet=NewDataSet
asinDA.Fill(asinDS,"Description")
</CODE>
Here is the error I recieved:
The ConnectionString property has not been initialized.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: The ConnectionString property has not been initialized.
Source Error:
(line 19)
[quote]
Line17:asinDA.SelectCommand=selectCMD
Line18:DimasinDSAsDataSet=NewDataSet
Line19:asinDA.Fill(asinDS,"Description")
</CODE>
I have this page up and running on another server.
I just copied the exact same asp.net file over and
changed the connection string in my configuration
file. There must be something different going on.
Owen
</blockquote id="quote"></font id="quote">
B.
DiscountASP.NET
http://www.DiscountASP.NET
infinitedes
09-24-2004, 12:35 PM
I got an error when I tried using the physical path as suggested:
Here is the code to my configuration file to connect to the database
[quote]
<configuration>
<!--applicationspecificsettings--><appSettings>
<addkey="strConnection"value="Provider=Microsoft.Jet.OLEDB.4.0;Datasource=
"e:\web\infinitedes\htdocs\_database\MusicStore.mdb ;"/>
</appSettings>
</configuration>
</CODE>
Here is the code that generates the error
[quote]
DimDSNasstring=ConfigurationSettings.AppSetting("strConnection")
DimmyConnAsOleDbConnection
myConn=NewOleDbConnection(DSN)
DimselectCMDAsOleDbCommand=NewOleDbCommand(strSQL, myConn)
selectCMD.CommandTimeout=30
DimasinDAAsOleDbDataAdapter=NewOleDbDataAdapter
asinDA.SelectCommand=selectCMD
DimasinDSAsDataSet=NewDataSet
asinDA.Fill(asinDS,"Description")
</CODE>
Here is the error I recieved:
The ConnectionString property has not been initialized.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: The ConnectionString property has not been initialized.
Source Error:
(line 19)
[quote]
Line17:asinDA.SelectCommand=selectCMD
Line18:DimasinDSAsDataSet=NewDataSet
Line19:asinDA.Fill(asinDS,"Description")
</CODE>
I have this page up and running on another server.
I just copied the exact same asp.net file over and
changed the connection string in my configuration
file. There must be something different going on.
Owen
infinitedes
09-26-2004, 07:31 AM
OK that problem is fixed but now I have another problem:
Unrecognized database format 'e:\web\infinitedes\htdocs\_database\MusicStore.md b'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.OleDb.OleDbException: Unrecognized database format 'e:\web\infinitedes\htdocs\_database\MusicStore.md b'.
Source Error:
[quote]
Line15:DimmyConnAsOleDbConnection
Line16:myConn=NewOleDbConnection(DSN)
Line17:myConn.open
Line18:DimselectCMDAsOleDbCommand=NewOleDbCommand("SELECTDISTINCTASINFROMDescription",myConn)
Line19:selectCMD.CommandTimeout=30
</CODE>
The error is indicated on line 17 where the connection is opened
Owen
bruce
09-27-2004, 11:26 AM
2 possible problems associated with this error
1) The database file is corrupted during upload (yes. this happens sometime with access).
Try download the db back to your computer and try open it with Access
2) The DB is created with an older version of MS Access.
[b]quote:Originally posted by infinitedes
OK that problem is fixed but now I have another problem:
Unrecognized database format 'e:\web\infinitedes\htdocs\_database\MusicStore.md b'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.OleDb.OleDbException: Unrecognized database format 'e:\web\infinitedes\htdocs\_database\MusicStore.md b'.
Source Error:
[quote]
Line15:DimmyConnAsOleDbConnection
Line16:myConn=NewOleDbConnection(DSN)
Line17:myConn.open
Line18:DimselectCMDAsOleDbCommand=NewOleDbCommand("SELECTDISTINCTASINFROMDescription",myConn)
Line19:selectCMD.CommandTimeout=30
</CODE>
The error is indicated on line 17 where the connection is opened
Owen
</blockquote id="quote"></font id="quote">
B.
DiscountASP.NET
http://www.DiscountASP.NET
Dillon
05-10-2008, 03:30 AM
Thank you very much for all you help I will try it. I post the outcome .
Dillon.
Hi, </o:p>
</o:p>
I had similiar problems several days ago, and it turned out to be my mdb file's corruption. Ifinally tired a utility called Advanced Access Repair (http://www.datanumen.com/aar/) to repair my Access MDB file. It works rather well for me.Hope this can help in the future.</o:p>
</o:p>
Alan</o:p>
phusit2008
07-12-2008, 01:27 AM
You can find the http://www.aspxcode.net
vBulletin® ©Jelsoft Enterprises Ltd.