Tameen Malik
Tameen Malik

Reputation: 1268

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?

Upvotes: 0

Views: 3115

Answers (4)

Mukesh Kumar
Mukesh Kumar

Reputation: 2376

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

Upvotes: 4

field_b
field_b

Reputation: 698

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.

Upvotes: 2

Ankush Jain
Ankush Jain

Reputation: 7079

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

Upvotes: 2

SLaks
SLaks

Reputation: 888107

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.

Upvotes: 2

Related Questions