Answered by:
is this correct format?????

Question
-
User373478236 posted
is this correct format?????
Dim strConnString As String = "Provider=Microsoft.Jet.OLEDB.4.0;data source=" & System.Web.HttpContext.Current.Server.MapPath("test.mdb")
Wednesday, August 17, 2011 4:48 AM
Answers
-
User-1199946673 posted
Yes, it will create a valid connectionstring, but you your database shouldn't be in the root of your website, where it can be downloaded. It should be in the App_Data folder, and then the connectionstriing will be:
Provider=Microsoft.Jet.OLEDB.4.0;data source=|DataDirectory|test.mdb
And instead of coding your connectionstring over and over again in your code, you better put it in the web.config file:
<connectionStrings> <add name="Test" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|Test.mdb" providerName="System.Data.OleDb" /> </connectionStrings>
And in your code, use
Dim strConnString As String = ConfigurationManager.ConnectionStrings("Test").ConnectionString
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, August 18, 2011 1:32 AM
All replies
-
User1927273029 posted
Hi,
Yes, this is the correct format please refer following link:
http://support.microsoft.com/kb/308100
It will be good if you can post your error.
Wednesday, August 17, 2011 4:57 AM -
User-1062158585 posted
dim dbconn,sql,dbcomm
dbconn=New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;
data source=" & server.mappath("northwind.mdb"))Wednesday, August 17, 2011 2:35 PM -
User-1199946673 posted
Yes, it will create a valid connectionstring, but you your database shouldn't be in the root of your website, where it can be downloaded. It should be in the App_Data folder, and then the connectionstriing will be:
Provider=Microsoft.Jet.OLEDB.4.0;data source=|DataDirectory|test.mdb
And instead of coding your connectionstring over and over again in your code, you better put it in the web.config file:
<connectionStrings> <add name="Test" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|Test.mdb" providerName="System.Data.OleDb" /> </connectionStrings>
And in your code, use
Dim strConnString As String = ConfigurationManager.ConnectionStrings("Test").ConnectionString
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, August 18, 2011 1:32 AM