Click here to Skip to main content
15,896,201 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello guys!
I quite a beginner for the environment MVC .NET
I am trying to connect my SQL db to my project MVC, but honestly I do not understand what to put as parameter.
My connection db sql is:
Server Name: CBL-LT138388\SQLEXPRESS
Instance Name: SQLEXPRESS
database : WebShop
User Name: sa
password: mypassword



C#
<connectionStrings>
<add name="myConnectionString" connectionString="server=localhost; database=WebShop; Integrated Security=True; uid=sa;password=" />
</connectionStrings>


What I have done:
1. Created a new project MVC.
2. trying to modify my myConnectionString, which allow me to register a new user and connect with them.
3. tried to modify my connectionStrings

When I try to executed the program, and register a new user, I do not see any table created.

What I have tried:

C#
<connectionStrings>
<add name="myConnectionString" connectionString="server=localhost; database=WebShop; Integrated Security=True; uid=sa;password=" />
</connectionStrings>
Posted
Updated 29-Dec-16 3:06am
Comments
[no name] 28-Dec-16 8:35am    
First thing is not to use the sa account for anything other than system administration.
Second thing, what do you think the connection string has to do with your problem? Connection string allow you to connect to a server and has nothing to do with table creation.
Francesco Bigi 28-Dec-16 8:59am    
Hello #NotPoliticallyCorrect,
thank you for your quick response.

I will keep in mind for sa account, and will use other account.

It should create a series of dbo as:
dbo.AspNetRoles
dbo.AspNetUserClaims
dbo.AspNetUserLogins
dbo.AspNetUserRoles
dbo.AspNetUsers

these tables should be generated automatically after the first execution and creation of a new user.




[no name] 28-Dec-16 9:11am    
No it should not. Connection strings have nothing at all to do with creating tables.

Your connection string looks very wrong: you are saying that you want Integrated Security, but then you supply a - very dangerous - user name "sa" and a - probably invalid - password of blank.

Getting a valid connection string is pretty simple: try setting up a connection in VS with the Server Explorer pane:
1) Open Server Explorer.
2) Right click "Data connections" and select "Add connection"
3) In the dialog that follows, select your DataSource, and database, specify the security info, and press the "Test connection" button.
4) When the connection works, press "OK"
5) Highlight your database in the Server Explorer pane, and look at the Properties pane. A working example of the connection string will be shown, which you can copy and paste into your app or config file.

But that won't create any tables for you. You need to create them and possible set up some test data before you get started on the rest.
 
Share this answer
 
Oook I see now.
When I follow the instruction which you wrote me it creates automatically a connectionStrings:


C#
<connectionStrings>
  <add name="WebShopEntities" connectionString="metadata=res://*/DAL.ClientModel.csdl|res://*/DAL.ClientModel.ssdl|res://*/DAL.ClientModel.msl;provider=System.Data.SqlClient;provider connection string="data source=CBL-LT138388\SQLEXPRESS;initial catalog=WebShop;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />

</connectionStrings>


Thank you very much guys!!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900