简体   繁体   中英

How to configure SQL Server + Web.config

I'm new to ASP.Net and have been given access to a solution that I am currently trying to get up and running. In Web.config, I see something like this:

<add name="FOOBAR_Connection" connectionString="Initial Catalog=FOOBAR;Data Source=QXQDESKTOP101\SQLEXPRESS;Connect Timeout=900;Password=foo; User ID=bar;" providerName="System.Data.SqlClient"/>
<add name="SiteMapConnectionString" connectionString="Initial Catalog=FOOBAR;Data Source=QXQDESKTOP101\SQLEXPRESS;Connect Timeout=900;Password=foo; User ID=bar;" providerName="System.Data.SqlClient"/>

Since I didn't get a database along with this solution, I am trying to create it in SQL Express. I named the DB FOOBAR to match what I see in the connection string. The Data Source was copied from the properties of the FOOBAR DB. I don't know how to create a User and Password for this DB. I'm hoping that once those are created and associated with the DB that I'll be able to get closer to running this application.

I think I need to create a user for the DB. Right? If so, how do I do this?

I'm assuming that since you're using Express the DB resides on the same server as the app so most likely (since it seems like you haven't configured any user info) you should be able to use integrated security (similar to what's specified in the connection string here: http://www.codeproject.com/Articles/361579/A-Beginners-Tutorial-for-Understanding-ADO-NET

Delete the User ID and Password parameters and use Integrated Security=True instead.

you can try this.

if you haven't set any login details to login with sql server then you can apply this connection string

<add name="FOOBAR_Connection" connectionString="Initial Catalog=FOOBAR;Data Source=QXQDESKTOP101\SQLEXPRESS;Connect Timeout=900;Integrated Security=True" providerName="System.Data.SqlClient"/>

and if you apply login credential to sql server then you connection string will be this

<add name="FOOBAR_Connection" connectionString="Initial Catalog=FOOBAR;Data Source=QXQDESKTOP101\SQLEXPRESS;Connect Timeout=900;Password=foo; User ID=bar;" providerName="System.Data.SqlClient"/>

to get login credential Please open you sql server management studio and in that please take Login name to userId and password to password else you can connect with first one.

Have a great day.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM