Connection string error using membership provider from WCF service

微笑、不失礼 提交于 2019-12-08 00:39:09

问题


The target is: I need a wcf method which will create user in the database.

I am using membership provider. and My client is SmartPhone/mobile device.

I wrote a method which will create user BUT when I test the method I get the following error.

error:

An error occurred while attempting to initialize a System.Data.SqlClient.SqlConnection object. The value that was provided for the connection string may be wrong, or it may contain an invalid syntax. Parameter name: connectionString

And I get this error in the following line:

Membership.CreateUser(name, password,email,"question","answer",true,out createStatus);

I am using the same connectionString that I use to read data from the database.

My connection string is:

<add name="MajangoEntities" connectionString="metadata=res://*/EntityModel.MajangoEntityModel.csdl|res://*/EntityModel.MajangoEntityModel.ssdl|res://*/EntityModel.MajangoEntityModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=tcp:sql2k298.discountasp.net;initial catalog=SQL2008R2_835021_myddb;user id=SQL2008R2_835021_mydb_user;password=mypassword;multipleactiveresultsets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />

Can anybody help me with some ideas??


回答1:


That connection string includes some Entity Framework specific data. Try instead just the "provider connection string" embedded within it:

 <add name="MajangoEntities" connectionString="data source=tcp:sql2k298.discountasp.net;initial catalog=SQL2008R2_835021_myddb;user id=SQL2008R2_835021_mydb_user;password=mypassword;multipleactiveresultsets=True;App=EntityFramework">

The rest of the data in there (the metadata, etc.) is just confusing SQL Server.



来源:https://stackoverflow.com/questions/8122274/connection-string-error-using-membership-provider-from-wcf-service

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!