Web.config: connection strings

R

R.A.M.

Hello,

I am beginner.
Could you help me please how to connect to SQL Sever using connection
string in Web.config?
I have:
<configuration>
<appSettings/>
<connectionStrings>
DataSource=PC\SQLEXPRESS;User ID=sa;Password=sqlserver;
Initial Catalog=DemoDotNET
</connectionStrings>
and code behind:
private string ConnectionString
{
get
{
SessionStateSection sss = new SessionStateSection();
return sss.SqlConnectionString;
}
}
but I got ConnectionString == "data source=localhost;Integrated
Security=SSPI" instead of text from Web.config.
How to programme it corectly?
Thank you very much!

/RAM
 
R

R.A.M.

That was a nonsense what I wrote.
I tried this way:

<connectionStrings>
<MSAccess>Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=App_Data/DemoDotNET.mdb;User ID=;Password=;Mode=Share Deny
None</MSAccess>
<SQLServer>DataSource=PC\SQLEXPRESS;User
ID=sa;Password=sqlserver;Initial Catalog=DemoDotNET</SQLServer>
</connectionStrings>

and code behind reading XML Web.config,
but my elements <MSAccess> and <SQLServer> are considered invalid.
Could anyone tell me please how to do it corectly?
Thank you.
BTW, my SQL connection string is not OK, I think...

/RAM
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top