asp.net editing the "connectionstrings.config " problem - asp.net

Thanks in advance.
I am attempting to edit the connectionstrings.config to connect to my sql server (locally) but it does not success.
The error message shown when i test in visual studio is:
Login failed for user 'TAT-PC\TAT'. The user is not associated with a trusted SQL Server connection
The content now in connectionstrings.config is:
<add name="NopSqlConnection" connectionString="Data Source=TAT-PC\SQLEXPRESS;Initial Catalog=hand;Integrated Security=False;Persist Security Info=False;User ID=TAT-PC\TAT;Password=;Connect Timeout=30"/>
The server is build by sql server 2005. And when i use the management tool to access
the config are:
Server type:Database Engine Server
Name:TAT-PC\SQLEXPRESS
Authentic: Windows Authentic
User Name:TAT-PC\TAT <===Which is Not editable
Password: <==no password
So, my question is how to edit the connectionstrings.config in order to connect to the server??(I have already create the schema "hand")

Have you assigned permission to your local user to sepcific database on sql server ? No need to mention any username or password. Just use trusted connection string.

Related

How to connect ASP.NET app to remote SQL Server

I need help connecting my Web App to a remote database (SQL Server).
I have tried many suggested solutions but I can't seem to come right.
This is how I connect to a local database, it works 100%:
<add name="DBCS" connectionString="Data Source=serverName;Initial Catalog=MVNE_Website;Integrated Security=True" providerName="System.Data.SqlClient" />
My ASP.NET Web App is hosted on one server, and the database is on a separate server.
The remote DB server is 100% configured to allow remote connections and firewall rules also adhere to the connection protocols. I think it is just my connection string that is incorrect but I don't know why??
Here it is(conn string for remote SQL server)
<add name="DBCS" connectionString="server=serverIP\serverName; database=MVNE_Website; Integrated Security=True" providerName="System.Data.SqlClient" />
I don't use a username or password when connecting to this remote SQL Server so I did not see a point in adding it in the conn string?
There can be a few reasons why this will not work. Here are 2 common ones:
Your web application will pass the username the application pool is running under, (which by default is some system user) to SQL Server. Change this to be a service account which has access to SQL Server.
If you are hopping across 2 or more servers to pass the credentials between IIS and SQL Server, you may need to implement Kerberos, which is a way to preserve the credentials. This is a complex network configuration thing.
Check point 1 first.
:/
In my web.config file custom errors mode was on RemoteOnly, so I turned it off and saw that my connection string was never the problem, the actual problem was that the app was trying to insert null into a primary key field that does not allow null, i never set the PK to auto increment
.. sorry and thanks

Error about ASP.NET security configuration(cannot connect to sql )

I've installed SQL Server 2012 and visual studio express for web 2012, I found that I couldn't connect to SQL via asp.net. I installed another SQL Server 2012 instance and changed datasource to (LocalDB)/v11.0, it then works.
But in the security configuration, though I've set the windows authentification,I get this error:
There was a problem with the selected datastore, which could be due to an invalid server name or credentials, or insufficient permissions. It may also be caused by the role manager feature not being enabled. Click the button below to redirect to a page where you can select a new data store.
The following messages may help diagnose the problem: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or cannot be reached. Verify that the instance name is correct and SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26-An error occurred while locating the specified server / instance)”
After testing the provider for storing site management data:Aspnetsqlprovide ’connection with sql,another error happens:
Failed to establish database connection.
If you haven't created a SQL Server database, exit the site administration tool, use the aspnet_regsql command-line utility to create and configure the database, then return to this tool to set up the provider.
Following the error message, I installed aspnetdb to this (LocalDB)/v11.0, and changed the codes in machine.config:
<connectionStrings>
<add name="LocalSqlServer"
connectionString="Data Source=(LocalDB)\v11.0;Initial Catalog=aspnetdb;Integrated Security=True"
providerName="System.Data.SqlClient"/>
</connectionStrings>
I also set IIS connection strings as codes above and changed Application pool identity to“LocalSystem”,but these errors still occurs.
I really hope someone can help me to handle this, thanks

Cannot open database "name" requested by the login. The login failed

I have deployed my web app on a server and I am trying to connect to a database on localdb. I am getting this error.
Cannot open database "hands.mdf" requested by the login. The login failed.
Login failed for user 'IIS APPPOOL\DefaultAppPool'.
I have created 'IIS APPPOOL\DefaultAppPool' login on the SQL server and given it access to all possible roles under user mapping.
This is my connection string:
<add name="constr" connectionString="Data Source=np:\\.\pipe\LOCALDB#D3DF8A08\tsql\query;Initial Catalog=hands.mdf;Integrated Security=True" providerName="System.Data.SqlClient" />
I have looked at similar requests and followed the advice with no luck. I have tried to change
"integrated security" to User ID=domain\administrator;pwd=password"
But still no luck.
Can someone help me with getting this working please?
Maybe 'IIS APPPOOL\DefaultAppPool' doesn't have permission to access hands.mdf directory.
All sorted problem was very simple at the end.
My original connection string was connecting to a local file i.e.
AttachDbFilename=hands.mdf
So when I changed to a attached SQL file
Initial Catalog=hands I should have removed (.mdf)

Correct connection string MS sql server database 2008

Was hoping for a little help with my connection string to ms sql server 2008 database.
Server Type: Database Engine
Sever name: MyServer
Authentication: Windows Authentication
User Name VAW\Username
the connection string I am using at the moment is as follow
<add name="Name" connectionString="Data Source=111.111.1.1;Initial Catalog=HRElearning;MultipleActiveResultSets=True;Trusted_Connection=true;" providerName="System.Data.EntityClient" />
Error I am getting is System.Data.SqlClient.SqlException: Login failed for user 'VAW\MAWSON$'.
I to agree using VS is the better way to go, but to understand connectionstrings in general, here is the site that explains it. Once you understand exactly what is going on, freehanding them is not difficult.
The connection string you have assumes the user you are running the app with is the user you want to connect with. If you want to run app with UserA and connect with UserB then you must specify the username and password and remove "Trusted_Connection=true".

Failed to generate a user instance of SQL Server due to failure in retrieving the user's local ap

This is my first time to deploy an asp.net web site. Everything is working fine on my local computer but when i published the web site on a remote computer i get the error "Failed to generate a user instance of SQL Server due to failure in retrieving the user's local application data path. Please make sure the user has a local user profile on the computer. The connection will be closed"
(only in pages that try to access the database)
Help pleaseee
In IIS under Vista/Windows 7/Server 2008 OS,
Select the application pool and then "advanced settings." Under "process model" find "Load User Profile" and set it to true.
SQL should now load under the default app pool account.
Try the following:
Start IIS
Open Application Pools by clicking on it
Right click on DefaultAppPool and select “Select Application Pool
Defaults”
Change “Identity” property to “NetworkService”
Save and exit IIS
You have to adjust your connection string according to your hosting server.
Modify the below section of web.config according to SQL server user name and password
<connectionStrings>
<add name="DBName" providerName="System.Data.SqlClient"
connectionString="uid=; pwd=; database=; server=;"/>
</connectionStrings>

Resources