connectionstring to sqlmembershipprovider asp.net - asp.net

I have added the sqlmembershipprovider to my dynamic data project for logging in and registering and such.
However, I am having problems with the connection string. The database is on a remote sql server 2008 database server.
Below I have a connection string for the entities:
<add name="xxEntities"
connectionString="metadata=res://*;provider=System.Data.SqlClient;provider connection string="Data Source=xx.xx.x.xxx;Initial Catalog=XX;Integrated Security=True;MultipleActiveResultSets=True""
providerName="System.Data.EntityClient" />
When I hit the membership provider, I get this error:
Keyword not supported: 'metadata'.
on this line of code:
System.Web.Security.Membership.GetAllUsers(0, 1, count)
Do I need a separate connection string for the provider? Or should I be able to use the above string with all my connections, including my membership provider?
thanks.

Try using this connectionString template + change the User-ID, Password, Initial Catalog
Provider=SQLOLEDB.1;Persist Security Info=True;Data Source=xxx.xxx.xxx.xxx;User ID=RemoteApp;Password=xxx;Initial Catalog=xxx;

Related

azure connection string format - adding in azure

I am rebuilding a web app in Azure, I used to have all my app settings and connection strings in azure. So I have put the app settings back in, but the connection string for the Azure SQL server doesn't like what I am putting in.
In the web.config I have this
<add name="LeisureInsureEntities" connectionString="metadata=res://*/LeisureModel.csdl|res://*/LeisureModel.ssdl|res://*/LeisureModel.msl;provider=System.Data.SqlClient;provider connection string="data source=tcp:leisureinsure.database.windows.net,1433;initial catalog=leisureinsure-website-preprod;persist security info=True;user id=XXXXXX;password=XXXXXX;multipleactiveresultsets=True;application name=EntityFramework"" providerName="System.Data.EntityClient" />
But I am having issues putting this into the value input field in azure.
You probably don't need the metadata information here. When I work with EF in Azure, I just use the connection string from the portal. e. g.:
data source=tcp:leisureinsure.database.windows.net,1433;initial catalog=leisureinsure-website-preprod;persist security info=True;user id=XXXXXX;password=XXXXXX;multipleactiveresultsets=True

Unable to find the requested .Net Framework Data Provider. It may not be installed

I am having problem in running my ASP.Net MVC project which is an admin project. It connects with a sql server database to fetch record. When I try to build and run, I am welcomed with this error: "Unable to find requested .Net Framework Data Provider. It may not be installed".
Here is the link to this error.
I have tried many solutions available on stackoverflow but none of them worked for me that's why I am posting this question here again. I tried changing the Target Framework version in Properties of project to all the available versions but all in vain. Here is the screenshot of my Global.asax.cs file which is causing this exception.
Below is the connection string of my project:
<add name="AlkhaleejEntities" connectionString="metadata=res://*/Models.Model1.csdl|res://*/Models.Model1.ssdl|res://*/Models.Model1.msl;provider=System.Data.SqlClient;provider connection string="data source=.;initial catalog=Alkhaleej;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient"/>
Connection string provided above indicates EF connection provider being used:
connectionString="metadata=res:///Models.Model1.csdl|res:///Models.Model1.ssdl|res://*/Models.Model1.msl;provider=System.Data.SqlClient;provider connection string="data source=.;initial catalog=Alkhaleej;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient"
Note that SimpleMembershipProvider can't use EF provider connection string (see this post) due to usage of SqlClient provider instead of EntityClient, hence it requires SQL Server connection string to interact with database.
Try open Server Explorer => Data Connections => right click your server connection, select Properties => add provided SQL Server connection string something like this one (leave EF connection string part as is, just add SqlClient provider connection string):
<add name="DefaultConnection" connectionString="Data Source=.;Initial Catalog=Alkhaleej;Integrated Security=True" providerName="System.Data.SqlClient" />
Then, change connectionStringName parameter on WebSecurity.InitializeDatabaseConnection method inside SimpleMembershipInitializer class to SQL Server connection string name as given below:
public class SimpleMembershipInitializer
{
public SimpleMembershipInitializer()
{
// other code part
if (!WebSecurity.Initialized)
{
WebSecurity.InitializeDatabaseConnection("DefaultConnection", "UserProfile", "UserId", "Email", autoCreateTables: true);
}
}
}
NB: The ideal setup for EF projects should include at least one SqlClient connection string and one EntityClient connection string, which may serve different providers with same target database.
Similar issues:
SimpleMembershipInitializer won't initialize
Unable to find the requested .Net Framework Data Provider. (SqlClient)
Can SimpleMembership and Entity Framework share a connection string?

How should i change connection string, for hosting asp.net site

connectionString=Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True providerName=System.Data.SqlClient
// what should i change in my connection string so i can host my asp.net site on aspspider.info...
//i get this errod
SqlException (0x80131904): User does not have permission to perform this action....and so on...
\SQLEXPRESS;Initial Catalog=dubaicargo;
Persist Security Info=True;User ID=username;Password=password;pooling=false
change your connection don't use integrated security. the above connection is just a sample. there are many ways to connect to yourdatabase with more security see this for list connection strings
Try to use SqlServer Authentication instead of windows authentication

ASP.NET MVC : Using the same database for Entity Framework and ASP.NET Membership

Im trying to user ASP.NET MVC3 with Entity Framework and ASP.NET Membership for authentication. I've set up an existing database as my application services database for membership.
When i create the entity data model through the wizard it adds the following connection string to my web.config.
<add name="DBEntities" connectionString="metadata=res://*/Models.DB.csdl|res://*/Models.DB.ssdl|res://*/Models.DB.msl;provider=System.Data.SqlClient;provider connection string="Data Source=PM\SQLEXPRESS;Initial Catalog=DB;Integrated Security=True;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient" />
I'm a noob so i don't really understand why but i tried using the same connection string for my membership provider and failed (probably because of this: providerName="System.Data.EntityClient" ?).
So i added a separate connection string to the same database and used it for the membership provider.
<add name="ApplicationServices" connectionString="Data Source=PM\SQLEXPRESS;Initial Catalog=DB;Integrated Security=True" providerName="System.Data.SqlClient"/>
It works fine when i use ASP.NET configuration to add user and etc. But when i run the application and try to do something like validating a user i get an error;
A transport-level error has occurred when receiving results from the server. (provider: Shared Memory Provider, error: 0 - The handle is invalid.)
I made a guess this has something to do with my connection strings. I'm hoping some of you experts can help. Cheers.
Have you tried restarting the server : A transport-level error has occurred when receiving results from the server ?
Not a solution or an answer, just a pointer to a similar issue..

connection string with no user name and password, asp.net

i have a website built in asp.net connecting to a sql 2000 db. within my web.config file, i have a connection string referencing a DSN. in order for my db connection to work i have to include the username and password within the string. for security reasons, is there any way to connect to my db without displaying the username and password. maybe a method to encrypt the information?? the trusted connection string method did not work for me.
current method
Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;
trusted method (did not work in my server environment)
Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;
You can encrypt connection strings in your web.config file.
See How To: Secure Connection Strings When Using Data Source Controls on MSDN.
For MySQL with port number
<add name="constring" connectionString="Server=localhost;Uid=root;Database=databasename;Port=3306;" providerName="MySql.Data.MySqlClient"/>

Resources