Monday, March 19, 2012

from asp classic & asp.net to Access database changing to sql server

View a printable version of this message!Hello,
We are re-writing our site in asp.net using sql server. Most of the site uses asp classic and it was to an access database. During the conversion we have everything working correct to SQL Server except for the asp.net connection string. There is an important part of the application using asp.net which works fine with our connection string to the access database. To recap our problem is the connection string from asp.net to sql server.

This code works fine for the asp.net to access in the web.cnfg file
</microsoft.web>
<connectionStrings>
<add name="SalesConnectionString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\inetpub\vhosts\themarketingvp.com\subdomains\vp\httpdocs\fpdb\salesMain.mdb" providerName="System.Data.OleDb"/>
<add name="ODBCSalesConnectionString" connectionString="DRIVER={Microsoft Access Driver (*.mdb)};DBQ=URL=E:\inetpub\vhosts\themarketingvp.com\subdomains\vp\httpdocs\fpdb\salesMain.mdb"/>
<add name="RawConnectionString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\inetpub\vhosts\themarketingvp.com\subdomains\vp\httpdocs\fpdb\salesMain.mdb" providerName="System.Data.OleDb"/>
<add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\inventoryStatus.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web
The code in the global.asa which works fine for classic asp to sql server also works fine and is as follows

'--Project Data Connection
Application("sales_ConnectionString") = "Driver={SQL Native Client};Server=DMSERVER01;Database=SQLsalesMain;UID=nTrack;PWD=nTrack2k3"
Application("sales_ConnectionTimeout") = 15
Application("sales_CommandTimeout") = 30
Application("sales_CursorLocation") = 3
Application("sales_RuntimeUserName") = ""
Application("sales_RuntimePassword") = ""

Our programmer who set this up is out for a couple of weeks and I would appreciate any help in the correct connection string from asp.net to the sql server database in the web.cnfg file

Thanks

<add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\inventoryStatus.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>

The above is your problem and your developer not knowing the meaning of User instance because it is for development only database unless you plan to deploy in Express the reason there is no such thing as User instance in full edition SQL Server so read the content of the MSDN link carefully or your code will not run. The text below is from the MSDN link. Hope this helps.

(SQL Server Express Edition allows only a single connection to an .mdf file when you connect with a connection string that has User Instance set to true.)


http://msdn2.microsoft.com/en-us/library/ms228037.aspx
http://www.connectionstrings.com/?carrier=sqlserver2005

|||

<add name="SalesConnectionString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\inetpub\vhosts\themarketingvp.com\subdomains\vp\httpdocs\fpdb\salesMain.mdb" providerName="System.Data.OleDb"/>

The above is the connection we are talking about.

Thanks...

|||That is not a SQL Server connection string that is the reason I gave you the link to the connection string site. Hope this helps.|||

Thanks,

I know that is not a SQL Server connection string. I was asking for help based on the way the salesMain connection string for SQL in the posted. I have how asp classic connects to SQL, which works fine and was asking how to get it to work with asp.net. I have both connection strings shown in the code in the first post.

Dave

|||

<add name="SalesConnectionString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\inetpub\vhosts\themarketingvp.com\subdomains\vp\httpdocs\fpdb\salesMain.mdb" providerName="System.Data.OleDb"/>


<connectionStrings>
<add name="salesMain" connectionString="Server=(local);Integrated Security=True;Database=salesMain;"
providerName="System.Data.SqlClient" />
</connectionStrings>

I have started the correct connection string but you have to add your server name to get it right because you cannot put SQL Server database in inetpub in a network drive because SQL Server decides where the database goes and it is the location below. What I mean is in RDBMS(relational database management systems) the server controls where the database goes. You still have to correct the previous connection string I pointed out to you because again there is no user instance in full SQL Server. You or your developer have to spend time to know connection strings and SQL Server permissions or your application will not run. Hope this helps.


C:\Program Files\Microsoft SQL Server\MSSQL\DATA


http://forums.asp.net/thread/1491403.aspx

No comments:

Post a Comment