I have my connection string set as
<add name="myconn" connectionString="server=192.X.Y.Z;user id=myusername;persistsecurityinfo=False;database=mydatabasehere;port=3306;Password=mypassword;" providerName="MySql.Data.MySqlClient" />
and later this error appear:
An exception of type 'MySql.Data.MySqlClient.MySqlException' occurred
in MySql.Data.dll but was not handled in user code
Additional information: Authentication to host '192.X.Y.Z' for
user 'myusername' using method 'mysql_native_password' failed with
message: Access denied for user
'myusername'#'crlspr-myipaddresshere.myacc.net' (using password: NO)
What will be the problem of this exception?
my connection seems to be ok since I just tested from MySQL Workbench as well in Visual Studio * Server Explorer
Why the error message get my ipaddress, 'myusername'#'crlspr-myipaddresshere.myacc.net'? maybe is a firewall problem.
Since my problem was the DB connection string and I was not sure which one #Raptoy suggestion will work or not, Then I went to MySQL website and get one of their example
4.14.2 Usage: Creating A New MVC Web Application
and the connection string that was generated by the wizard finally works:
<add name="myconn" connectionString="server=192.X.Y.Z;user id=myusername;password=mypassword;persistsecurityinfo=True;database=mydatabasehere" providerName="MySql.Data.MySqlClient" />
You will notice the connection string contains:
server
user id
password
persistsecurityinfo=True
database
Related
I've seen this error answered for other people, but I can't seem to get it to work. I'm trying to connect to a SQL Server Database project locally.
I'm getting this error thrown on Open() when I do the follow:
SqlConnection conn = null;
conn = new SqlConnection(connection)
conn.Open()
Where connection is a connection string passed from my webconfig. I've found examples online and tried these three connection strings and I get the same error every time:
<add name="TICKETING_CONNECTION" connectionString="Server=(local); DataBase=Ticketing_DB; Integrated Security=SSPI"/>
<add name="CONN"
connectionString="Data Source=localhost; Integrated Security=SSPI;Initial Catalog=Ticketing_DB"
providerName="System.Data.SqlClient" />
<add name="CONN2"
connectionString="Data Source=(local);Initial Catalog=Ticketing_DB;"
providerName="System.Data.SqlClient"
/>
Could the problem be stemming from the path of where the database is located on my machine? I've tried copying the c:\ path but didn't have any luck. I've seen some examples online use a .mdf file, but my project does not have this file either.
This is my first time trying to connect to a database project, so any help or advice would be greatly appreciated
If you are using Visual Studio try going to the Server Explorer and Right click on Data Connections and Add new connection by selecting DataSource as Microsoft SQL Server and provider as .net framework provider for SQL Server.
Under the server name check for the SQL Server if it is listed with your machine name.
Then try to provide the database details and user name and password for SQL Authentication or select windows for windows authentication. Then do a test connection. If it is fine on click of OK it will add the data connection.
Right click the properties of data connection which is newly added and navigate to properties to extract the connection string. Compare it with yours. This can help you troubleshoot the issue.
This is my first MVC Website with a database hosted on Azure.
I have deployed the database and the website. However I get an Access Denied error message:
[SqlException (0x80131904): A network-related or instance-specific
error occurred while establishing a connection to SQL Server. The
server was not found or was not accessible. Verify that the instance
name is correct and that SQL Server is configured to allow remote
connections. (provider: Named Pipes Provider, error: 40 - Could not
open a connection to SQL Server)]
What I don't get is that I can run the app via Visual Studio connected via the Azure connection string locally without any problems. I can speak to the db remotely but not within Azure!!!
Here's the connection string I'm using:
<connectionStrings>
<add name="myConnString"
connectionString="metadata=res://*/Models.MyModel.csdl|res://*/Models.MyModel.ssdl|res://*/Models.MyModel.msl;
provider=System.Data.SqlClient;
provider connection string="
Data Source = tcp:mybdurl.database.windows.net,1433;Initial Catalog=myDb;
persist security info=True;
User ID=MyId;
Password=MyPassword;
MultipleActiveResultSets=True;
application name=EntityFramework""
providerName="System.Data.EntityClient"
/>
</connectionStrings>
I'm guessing there is a missing magic Azure element that allows access. Both are in the same data centre and within the same account.
Cheers
I was publishing the web.config file individually in Visual Studio, not realising it wasn't actually updating on Azure. I went back to old fashioned FTP and indeed the live web.config was still the original not the one for Azure.
Manually uploaded it and it worked!
What didn't it publish???
I worked with c#(started to work). At first I created model. And by this model I created MVC 5 controller with views, using Entity Framework. I thought that all correct (that necessary table will be created by this model, and I can worked with local database), but when I would like to run my application and go to this page http://localhost:49640/ControllerName I get this error:
Additional information: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 52 - Unable to locate a Local Database Runtime installation. Verify that SQL Server Express is properly installed and that the Local Database Runtime feature is enabled.)
I tried to find some solution, but I didn't. As I understood it can be some problems with connectionStrings in Web.config or some problems with connection to server, but how solve this problem?
My connection strings:
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-MusicApplication-20150620120938.mdf;Initial Catalog=aspnet-MusicApplication-20150620120938;Integrated Security=True"
providerName="System.Data.SqlClient" />
I download SqlLocalDb and installed it, this solve my problem. This link connection to local db failed 52 helped me.
I've got a problem to connect my website with database. The problem is, if I am trying install my website in IIS on the same machine where database is located, I am receiving error: "Login failed for user". But when I am installing my website on a different machine, connection with database works fine. My connection string looks like this:
<add name="DBConnection"
connectionString="Data Source=myServer; Intial Catalog=myDataBase; User Id=myUserId; Password=myPassword"
providerName="System.Data.SqlClient`" />
I have to install webservice on the same location where database is with the same password and login. How correct connection string should look like?
I have used IIS before, but I've never used a database and I've never done a web app. I did the same steps for putting a site onto IIS and everything works EXCEPT for when I go to a page that has a DB connection on it. I've tried a lot and this is all I get.
A network-related or instance-specific error occurred while establishing a >connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 50 - Local Database Runtime error occurred. Cannot create an automatic instance. See the Windows Application event log for error details.
Windows Application Event Log:
Cannot get a local application data path. Most probably a user profile is not loaded. If LocalDB is executed under IIS, make sure that profile loading is enabled for the current user.
This was built in Visual Studio and I have a SQL Express DB.
I posted my connection strings, any help is greatly appreciated.
I have added this to my applicationHost.config:
<add name="DefaultAppPool">
<processModel identityType="ApplicationPoolIdentity" loadUserProfile="true" setProfileEnvironment="true" />
And now I get:
An attempt to attach an auto-named database for file |MY DB1 FILE| failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\DB1.mdf;Initial Catalog=aspnet-ICCAA_VIZIER-20150223043129;Integrated Security=True" providerName="System.Data.SqlClient"/>
<add name="ConnectionString" connectionString="Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\DB2.mdf;Integrated Security=True;Connect Timeout=30" providerName="System.Data.SqlClient"/>
I was able to figure it out. I changed all my data connections to .\SqlExpress. Which led me to another error of:
Login failed for user ‘NT AUTHORITYNETWORK SERVICE‘
To fix this I followed this guys article to figure it out.
Login Failed For user NetworkService