Error in webconfig file

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
15 years ago
Okay we are getting somewhere then.

You probably do not have create database permissions. Did you specify windows authentication or SQL?

Personally I prefer to create the Db manually as I can create a separate sql login for nopcommerce.

Manual creation of database (presumes you have direct access to the SQL Server)
---------------------------

1 - Open up SQL Server Management Studio and connect to your SQL Server. Your credentials must have create database privaledges)
2 - Right click Databases and choose "New Database"
3 - Give your database a recognisable name e.g. nopCommerceDB
4 - If you want to change the paths to your database files (default is "C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA") then you can change the Path in the "Database Files" section.
5 - Click OK to create the database

With the database created, now we need access for our application so lets create a new SQL Server login and map this to the nopCommerceDB.

1 - With SQL Server Management Studio open, right click security (under the server node) and select "New > Login"
2 - Give your login a name e.g. "nopCommerceUser"
3 - Select SQL Server authentication (it is unlikely you will use Windows authentication in a public environment)
4 - Give your login a strong password - something like Hell0k1tty!
5 - Untick "Enforce password policy"
6 - At the bottom of new login window, select the nopCOmmerceDB from the Default Database drop down list.
7 - Next with the new login window still open, select "User Mapping" on the left hand side of the window.
8 - You will see a list of databases on your server. Tick the "Map" checkbox next to your nopCommerceDB database and in Default Schema, type "dbo"
9 - At the bottom of this window (Database Role Membership), tick "db_owner"
10 - Click OK to create the login.

Now if you expand the security > users node of your nopCommerceDB you will notice that SQL Server has automatically created the "nopCommerceUser" for that database.

So now we have access to the database. Next we need to add our nopCommerce database objects.

In the install directory of the nopCommerce their is a scripts directory that contain the database creation scripts.

Copy these to a location that you can access from sql server management studio.

1 - Open nopCommerce_createDatabase.sql in Management Studio
2 - Make sure that the context is set to your nopCommerceDB database (top left, select NopCommerceDB from dropdown)
3 - Click the "Execute" button or press F5 to run the script.
4 - You should get a message saying "Command(s) completed successfully."
5 - Now open nopCommerce_createData.sql
6 - Again, making sure you have your nopCOmmerceDB database selected, execute the script.
7 - This time you will get quite a few messages displaying how many rows were affected for different actions.
8 - All being well, expand your database in object explorer (on the left) and you should see some tables under tables.

So at this point we have created a database and have the necessary security in place to connect to it.

Now to edit web.config to connect to our database.

1 - Open up web.config and add the following within the <connectionStrings> nodes. You should end up with something like below:

  <connectionStrings>
       <add name="NopSqlConnection" connectionString="Data Source=YourServerName;Initial Catalog=YourDatabaseName;User ID=TheLoginNameYouCreated;Password=TheStrongPasswordYouGaveYourLoginName;"/>
  </connectionStrings>


I have highlighted the things you will need to change depending on your configuration.

If you are in a hosted environment you may need to check with your host what the correct settings are.

Also in a hosted environment it's unlikely you will create the database or login through SSMS. Normally, you have an option to create a SQL Server database in your hosts control panel, as well as creating user accounts for that database (the user you create is then used in the connection string to connect to your db).

Hopefully that gives you the information you need to create the database manually.

I ran through the process myself as I wrote that so can confirm if you follow these steps it should work.

If you still get problems after this, try starting from scratch in IIS. Create a new Virtual Directory, make sure it's set as an application then copy the contents of nopCommerceWeb to the root directory. Make the changes to web config and then try navigating to the site.

Cheers,

Ben
15 years ago
(I hope I have not posted this more than once, apologies if I have)
Thanks Ben,
Re: Did you specify windows authentication or SQL?
Answer: Windows Authentication

Thanks also for the excellent description of how to create the db manually.

I must learn so will have a go.

Regards

John
15 years ago
Many thanks Ben for the clarity of the instructions given.

I followed these carefully and all seemed well until I arrived at

8 - All being well, expand your database in object explorer (on the left) and you should see some tables under tables.

I can see no tables.

Any ideas where I may have gone wrong please?

If I wish to start again what is the best way to delete the database created so far.

btw I am using SQL Server Management Studio Express

Thanks John
15 years ago
John,

Have you refreshed object explorer?

Do you have permissions to create tables i.e. can you right click the tables node and create new table.

Also, did you make sure you switched the context to the nopCommerce DB when you ran the scripts - it probably selected MASTER by default.

Cheers,
Ben
15 years ago
Thanks Ben
Some progress I can now see the tables created in sql server
I ammended the web.config file but not so sure this is correct

  <connectionStrings>
      <add name="MyRegServerName\SQLEXPRESS" connectionString="Data Source=Localhost/NopCommerce;Initial Catalog=nopCommerceDB;User ID=nopCommerceUser;Password=password;"/>    
  </connectionStrings>

When I run  default.asp I go to http://localhost/NopCommerce/install/install.aspx

On step 2
If I select Use SQL Server account and use the username and password I think is correct I get a red error
Login failed for user 'username'. The user is not associated with a trusted SQL Server connection.

If I select Use integrated Windows authentication (ASP.NET account: NET100PC\ASPNET)
I go to step 3
Existing database name nopCommerceDB

I go to step 3 and receive error
An error occured: Cannot open database "nopCommerceDB" requested by the login. The login failed.
Login failed for user 'NET100PC\ASPNET'.
Running scripts from file: D:\Inetpub\wwwroot\NopCommerce\install\Scripts\nopCommerce_createDatabase.sql
Can you see where I am going wrong please?
Many thanks
John
15 years ago
John,

If you have created the database manually then there is no need to run Install.aspx.

If you followed my instructions you should have a database e.g. nopCommerceDB and a login for that user e.g. nopCommerceUser.

You should use SQL Server authentication in most cases, not Windows Authentication.

Your Data Source should be in the format ServerName\InstanceName. Therefore, if you are using SQL Express and using the default instance, your Data Source should be "localhost\SQLEXPRESS".

Initial Catalog is the name of the database, so in my example it is "nopCommerceDB".

So your connection string (presuming) you have the default named instance of SQLEXPRESS should be:

<connectionStrings>
<add name="NopSqlConnection" connectionString="Data Source=localhost\SQLEXPRESS;Initial Catalog=nopCommerceDB;User ID=nopCommerceUser;Password=password;"/>
</connectionStrings>

You should leave the name as "NopSqlConnection" - in your post you appear to have this as your server\instance.

So the only thing you would need to change in the above, is your Initial Catalog (database name) and the user id and password.

Then, you are ready to launch the site (not the install) so just browse to http://servername/NopCommerce/Default.aspx.

Hope this helps.

Regards,
Ben
15 years ago
Many thanks Ben
I can now open the shopping cart so I can now sart to go further.

Just a point which may assist someone else.
I  created an initial database successfully once but then had to delete it.

After creating a new database in Server Management Studio Express,
When I opened up the install script file to create the database tables this was executed but I received messages such as

Msg 2714, Level 16, State 6, Line 1
There is already an object named 'Nop_CustomerRole_Discount_Mapping' in the database.
Msg 2714, Level 16, State 3, Procedure Nop_ShippingMethodDelete, Line 8
There is already an object named 'Nop_ShippingMethodDelete' in the database.
Msg 2714, Level 16, State 6, Line 1
There is already an object named 'Nop_ShippingMethod' in the database.
Plus many more

Eventually I found this answer
In management studio, go to tools, options.  on the left, select Scripting.  In the options to the right, select "Include If Not Exists", and make that option "true"...then rescript your objects.
This solved the problem
14 years ago
Hello

I followed all instruction. In database there are all records. Building of project in Visual Studio 2008 was finished successfully, but when i started debugging project (F5)- there appeared an error

"A project with an Output Type of Class Library cannot be started directly. In order to debug this project, add an executable project to this solution which references the library project. Set the executable project as the startup project."

How can I correct this?

thanks for help.
14 years ago
Right-click on your "nopCommerceStore project" and click "Set as StartUp project"
14 years ago
it's works.
many thanks.

but appeared one more error

"Login failed for user 'nopUSer'. The user is not associated with a trusted SQL Server connection."

how to associate?
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.