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

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

Related

Unable to connect using sql authentication through an asp.net web app

I cannot get my web app to connect to the database when running the app. I can connect in the SQL Server object explorer and I took the connection string from the connections properties
Here is my connection string :
<add name="Quotes.DAL.QuotesConnection"
connectionString="Data Source=(localdb)\v11.0;Initial Catalog=TestDB;Integrated Security=False;User ID=sa;Password=***;Connect Timeout=15;Encrypt=False;TrustServerCertificate=False"
providerName="System.Data.SqlClient" />
I can connect as SA and I can create the database that it points to in Management Studio. When my app tries to connect via Entity Framework I get the following error :
System.Data.SqlClient.SqlException (0x80131904): Login failed. The login is from an untrusted domain and cannot be used with Windows authentication. at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject,
I'm running Windows 7 as a home dev machine so there is no Active Directory.
Can anybody explain why this might happen?
I have found that this is probably because I have Entity Framework in another assembly. I created a new web application and its connection string works. When it try the same connection string in my DAL it fails with this same error!
Thanks
It may be because of setting Integrated Security=False, I have never set it to false. I normally use just the bare minimum Server=myServerAddress;Database=myDataBase;User Id=myUsername;
Password=myPassword; when setting up my connection strings with sql authentication, only adding things as I need them.
The other issue I see is using SA to connect to the database. This breaks almost every best practice in the book and I would recommend creating an app specific password for when you roll out the program. The reason being is the GOD ACCESS account for the server will have its password in plain text in the app.config file. Just something to keep in mind.
EDIT: After some comment discussion the connection string was in the wrong config file.

Configure IIS 8 for SQL Server Authentication

I'm getting the following error when trying to query SQL Server 2012 from Windows 2012 IIS 8.5, in an MVC 4 website:
SqlException (0x80131904): Login failed for user [domain/user]
I have the connection string in Web.config set up just the way we did it back in the olden days:
<add name="MYPROJECT.Properties.Settings.defaultConn" connectionString="Data Source=MYSERVER;Initial Catalog=MYDATABASE;Persist Security Info=True;User ID=MYUSER;Password=MYPASSWORD"
IIS8 seems to be using an Application Pool to login, bypassing the connectionstring in Web.config.
Database and Website are on different servers. Is there a straightforward way that I can configure IIS to bypass the Application Pool and read the connectionstring from Web.config?
If Persist security info is set to true, it will be ignored. From MSDN
The ConnectionString is similar to an OLE DB connection string, but is not identical. Unlike OLE DB or ADO, the connection string that is returned is the same as the user-set ConnectionString, minus security information if the Persist Security Info value is set to false (default). The .NET Framework Data Provider for SQL Server does not persist or return the password in a connection string unless you set Persist Security Info to true.

plesk panel using host user in Connection String in asp.net

I have developed a web apllication in asp.net with its connection String in web.config file and working very well in localhost. But when i deployed to hosting server using windows shared hosting it fives the error
Logic failed for user anama76
where anama76 is my domain user.My database userName is anama_Muneeb. I am finding it difficult to know that why connection string is using the domain user to connect to Db.
I have used connection in web.config to make sql server authentication
What is the solution
Your connection string must match the user name:
<add
name="ConnectionString"
connectionString="Data Source=your_database_server;Initial Catalog=your_database_name;User Id=anama_Muneeb;Password='your_password';"
providerName="System.Data.SqlClient"/>

connectionstring to sqlmembershipprovider 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;

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