-1

I followed the whole tutorial here http://www.w3schools.com/website/webpages_demo.asp and have all the files in my WebMatrix Demo website project as instructed. I set up a "Northwind.sdf" database and created a table "Users" (having Id, CompanyName,City, Country columns) but my website could not run.

Connection string "Users" was not found, is the issue

Line 2: WebSecurity.InitializeDatabaseConnection("Users", "UserProfile", "UserId", "Email", true);

This line is highlighted in red. I don't know how to fix it. I read somewhere about "public static class WebSecurity" but I don't know where to put it, which file and which line (right place for it if inserting it can solve the issue).

When I delete _AppStart.cshtml, and by hitting Run button in WebMatrix for testing, my Demo Website can run but Pages like Register, getCustomers, Customers are missing the database. Please help me to set up things properly in order to solve the problem. I'm new to this.

4
  • 2
    Bee wary of w3schools:w3fools.com . Goto the horses mouth instead: asp.net/web-pages/tutorials
    – Jon P
    Jun 5, 2014 at 0:57
  • Thank you. May you please look into my problem with _AppStart.cshtml? The other files work fine.
    – ptran
    Jun 5, 2014 at 5:54
  • Sounds like the connection string is missing, probably from the web.config file.
    – Jon P
    Jun 5, 2014 at 6:04
  • Here's another reason to run away from w3schools: most professional development organizations use Visual Studio, not webmatrix. Jun 5, 2014 at 6:32

1 Answer 1

1

The error message says it all

Connection string "Users" was not found

When you are unfamiliar with code/error/etc you should try to read the message

  1. Connection string? It sounds clear
  2. "Users"? It's even ponting to the particular string

    Next thing is the method where the error has occurred

    WebSecurity.InitializeDatabaseConnection("Users", "UserProfile", "UserId", "Email", true);

  3. Is "Users" in the parameters somehow similar to the error above?

  4. How WebSecurity.InitializeDatabaseConnection is constructed?

IntelliSense or a search in the internet will point you to http://msdn.microsoft.com/de-de/library/gg569134(v=vs.111).aspx where you can see that the first parameter is

connectionStringName
The name of the connection string for the database that contains user information.

2
  • Thank you for your replies. I figured these things: _AppStart.cshtml should have nothing but WebSecurity.InitializeDatabaseConnection(...); 2. W3School tutorial created confusion by giving 2 databases, Northwind and UserProfile. I managed to have to use only 1 database and 2 tables (1 for customers, 1 for users). W3School introduced a simple asp.net webpage, yet the webpage has few glitches and I had to fix them on my own. Thanks again.
    – ptran
    Jun 5, 2014 at 7:55
  • Did you find the reason of "Connection string "Users" was not found"? Jun 5, 2014 at 8:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.