简体   繁体   中英

connection string is not working in asp.net webforms

i registered my website on somee.com. for that i have uploaded MS SQL database. i was wrting this connection string in my code:

connectionString="metadata=res://*/nrcsaEntities.csdl|res://*/nrcsaEntities.ssdl|res://*/nrcsaEntities.msl;provider=System.Data.SqlClient;provider connection string="data source=My-PC;initial catalog=nrcsa;integrated security=True;multipleactiveresultsets=True;App=EntityFramework""

now as i registered somee.com is providing me new connection string that is:

workstation id=nrcsadb.mssql.somee.com;packet size=4096;user id=DuaZoya_SQLLogin_1;pwd=abcd;data source=nrcsadb.mssql.somee.com;persist security info=False;initial catalog=nrcsadb

i have changed connectiong string in file web.config by replacing this first connection string with provided connection string by somee.com

PROBLEM:

This replacement is generating warning that:

 System.ArgumentException: Keyword not supported: 'user id'.

how to solve this problem?

In the web.config file ....

     <connectionStrings><add name="nameofConnection" connectionString="Data   Source=servername; Initial Catalog=DatabaseName; User ID=UserName; Password=Password;"/>  </connectionStrings>
 <system.web>
<compilation debug="false" targetFramework="4.0" />  </system.web>

you can edit target Framework according to you.

from : http://dotnet-developers-cafe.blogspot.in/2013/08/create-connection-string-in-aspnet.html

You're using Entity Framework.

Entity Framework has its own connection string which contains a reference to the EF metadata ( metadata=... ) as well as the inner connection string to connect to the actual database.

You need to insert your actual database connection string inside the EF connection seting, in the provider connection string=... section.
You will also need to add multipleactiveresultsets=True to their connection string; EF needs that setting.

Don't replace the whole connection string. You will need to remove the Integrated Security = true section and replace it with user=DuaZoya_SQLLogin_1;password=abcd.

Also change the data source to nrcsadb.mssql.somee.com.

You pretty much just need to replace values in your existing connection string with the values provided.

As you are using entity famework, then your connection string will look like

<connectionStrings>
  <add name="BlogContext" 
        connectionString="metadata=res://*/BloggingModel.csdl|
          res://*/BloggingModel.ssdl| res://*/BloggingModel.msl;
          provider=System.Data.SqlClient 
          provider connection string=&quot;data source=[you somee.com connetion string];&quot;" providerName="System.Data.EntityClient" />
</connectionStrings>

what you need to do is simply change the value of data source from the actual connectionstring provided by somee.com

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