I need to access a view on an oracle server with an ASP.NET website. It works if I debug the website through visual studio(press F5 in VS2012), but when I go to the version hosted on my local IIS (LocalHost/) I get this error:
Oracle.DataAccess.Client.OracleException: ORA-12154: TNS:could not resolve the connect identifier specified
A lot of the information I'm finding is related to the deprecated System.Data.OracleClient and I'm using Oracle.DataAccess.dll File version 4.112.3.0, Assembly version 2.112.3.0.
I set the AppPool it's running in to Enable 32-Bit Application=True based on some other people with a similar issue, I think everything else is default settings.
I've tried using the gacutil to make sure it is installed in the gac.
I also made a small winForms application that works and can access the data.
I've tried a couple connection strings:
This one works:
"Data Source=SOURCE;Persist Security Info=True;Password=****;User Id=****;"
This one doesn't work, I can't figure out a valid SERVICE_NAME:
"user id=****;password=****;data source=(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=****)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=****)));"
I always get this error:
Oracle.DataAccess.Client.OracleException: ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
Places I've looked for SERVICE_NAME
I checked the connection I was able to establish with the first connection string and the SERVICE_NAME was either blank or sys$users depending on the query I ran.
I found three files named tnsnames.ora; one was completely blank, the SERVICE_NAME in the other two were Worker and <database service name>.
NOTE: I don't have access to the server, just credentials for this one view.
I found the SERVICE_NAME with this: select sys_context('userenv','db_name') from dual; and used the second connection string from the question:
"user id=****;password=****;data source=(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=****)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=****)));"
Thanks for all the help.
Related
Trying to connect to MySQL on my web host, using Connector/Net C#/WinForms in Visual Studio 2012 Update 3, but getting the below error message:
Authentication to host '1.1.1.1' for user 'username#mydomain.com' using method 'mysql_native_password' failed with message: Access denied for user 'username#mydomain.com'#'2.2.2.2' (using password: YES)
string connectionString = "SERVER=1.1.1.1;PORT=3306;DATABASE=databaseName;UID=username#mydomain.com;PASSWORD=mypassword;";
MySqlConnection connection = new MySqlConnection(connectionString);
connection.Open();
I am connecting remotely, have whitelisted my IP (and even temporary whitelisted all (%) to test), triple checked the username and password and IP.
I originally tried the username without the domain ( username rather than username#mydomain.com) but it gave me the below error:
Authentication with old password no longer supported, use 4.1 style passwords.
Any assistance would be much appreciated, thanks!
Its problem of 'Remote Database Access Hosts'.
"You can allow external web servers to access your MySQL databases by adding their domain name to the list of hosts that are able to access databases on your web site."
MySql access is not granted to IP address of the system at which application is running.(in your case its '2.2.2.2' ).
Note:- '2.2.2.2' is your public IP address.
Two possible things:
MySQL is case sensitive make sure that the case of Database= in your connection string matches with the actual database name
You may have to grant privileges to the user.
I hope this help you.
Check your application settings file (or wherever you have stored the connection string).
In my case the application was using the old connection string (which was not valid). I was assuming that the change I made in the code of the settings file is reflected to the designer (of the settings file). But it was not!
After creating a new user in MySQL, in MySQL Workbench "Test Connection" will succeed but the C# MySqlConnection.Open() will throw the same exception and message as the question (tested with localhost and 127.0.0.1 and the local ip address).
The reason is that MySqlConnection.Open() will somehow use SELECT privilege, and you need to at least enable the SELECT privilege for the new user. The error message is misleading.
This might be related to the case of specific Membership SQL Server based instructions on ASP.NET 4.5, workaround is to create new membership in web.config, drop mvc 4 AccountControler and use old from MVC3 more here or in the internet:
http://www.nsilverbullet.net/2012/11/06/using-mysql5-as-membership-backend-for-aspnet45-mvc4-application/
In my case updated password was not used. I just generated the password using Password Generator and copy it but forgot to click Change Password.
Also check the user is added to the database and has Privileges.
For me, using the actual IP address instead of the domain name solved the problem
While Whitelisting my Ip on cpanel i had accidentally put a space in there after my ip address.[Should have been handled by them]
I added the ip again and it worked.
In my case, the problem was misleading as well.
Had quite a few windows terminals running "the same" .net app all connecting to a remote MySQL server (installed in a windows server machine). However, only one always popping the specific error when anyone clicked to run the .net application. ODBC test connection passed successfully, and no matter if the error popped, when presing OK the application continued loading successfully finally and then worked fine.But again afterwards , when anyone tried to run in for the first time the message appeared. and I repeat only in this specific terminal! The fix finally came when I noticed, that it was only in this specific terminal with the problem that we had forgotten DHCP enabled! and "although it was given always the same IP" from our IT policies, however it only worked when we disabled DHCP and set this IP, SUBNET and GW, as fixed !
Check with a program like Navicat that the mysql server user has a native password. Everything is correct but if you are getting this error check the version of the link DLL
This error; Mysql.Data.dll and Mysql Server version mismatch error. Download and install an older version
https://downloads.mysql.com/archives/c-net/
Mysql Version < 4.5
Mysql.Data.Dll version= 6.0.3
I've been given a site that was created by someone else and I'm now trying to test it. I can compile the system without any problems but when I try to log in to the website, I get the error:
"EntityException occured. A first chance exception of type 'System.Data.EntityException' occured in System.Data.Entity.dll. Additional info: The underlying provider failed on Open."
Furthermore, if I dig deeper, I see an InnerException of Cannot open database \"MyDB\" requested by the login. The login failed. Login failed for user 'name\\owner'.
I've read similar problems on the web and it seems like its a problem with database connections? I've tried multiple 'solutions' that include messing around with the connectionString but nothing works.
What I think the system wants to do is connect to a .mdf located in a separate project's App_Data. Anyway, here's the connectionString code that I received originally:
add name="NameServiceContext"
connectionString="Server=tcp:qiu5vg5yhv.database.windows.net,1433;Database=MyDB;User ID=MYID;Password=MYPASS;Trusted_Connection=False;Encrypt=True;Connection Timeout=30;"
providerName="System.Data.SqlClient"
Quick question, what is the tcp:...... stuff? I'm assuming it was generated somehow, but how?
I've tried 'fixing' the problem and ended up with something like this:
add name="NameServiceContext"
connectionString="data source=./SQLEXPRESS;AttachDbFilename=C:\Users\owner\Documents\MyERP\App_Data\MyDB.mdf;Integrated Security=True;Connect Timeout=30;"
providerName="System.Data.SqlClient"
Both methods give the same errors and I'm out of ideas. How would I go about fixing this?
Also, when I connect to a db via tools>connect to database > MS SQL db file, I get an option between 2 data sources, ./SQLEXPRESS and (LocalDB)\v11.0. Do I have to include both of them? If so, how?
The original connection string refers to a Microsoft Azure instance. A typical connection string to Azure looks like:
Server=tcp:[serverName].database.windows.net;Database=myDataBase;User ID=[LoginForDb]#[serverName];Password=myPassword;Trusted_Connection=False;Encrypt=True;
Your server name is qiu5vg5yhv.database.windows.net. Most likely your credentials are incorrect.
It is as Andrew said, you don't seem to have access to the actual database. Simply download either "SQL Server Management Studio" or "SQL Server Management Studio Express" (depend on which version of database you are using) and try to connect.
If you connect successfully, check if you can query the database of your project.
If you connect unsuccessfully, contact your system admin to arrange access.
If you want to understand more about connectionstring or create one, use the following site for template: http://www.connectionstrings.com/sql-server/
You can get the necessary database details by viewing the Properties of your database via "SQL Server Management Studio" (right click and select Properties --> View Connection Properties)
I met the same question. The key step is here.
I used vs 2013 update 4.
When you configured your SQL in azure, it generated a connect string.
Quick Background
I received code from a third party (contracted software) that I have to move onto my servers. When I run the code using their connections and service references, everything works well. When I debug locally, everything works well. My problem only occurs when I try to run the application/service(s) after I move them onto my server.
The services (or their respective references) are at the heart of what's causing the issues. I created a test client to try to debug the services, and it's accessing the service, but erroring when it tries to connect to the SQL Server inside the service. The code appears to use the Entity Framework which I am admittedly not familiar with yet.
Errors/Issues
When I use my test client to call a function inside the service reference, it errors out when it tries to connect to my SQL database:
using (ApplicationDefinitionDBEntities appDefDb = new ApplicationDefinitionDBEntities()) //ERROR
Here's the error I receive (domain and server names have been made generic):
System.Data.SqlClient.SqlException (0x80131904): Login failed for user 'MYDOMAIN\APPSERVERNAME$'.
I found the app.config that is referenced by the .edmx file (ApplicationDefinitionDB.edmx) and its accompanying files. Here is the connection string (made generic):
<add name="ApplicationDefinitionDBEntities"
connectionString="metadata=res://*/Data.ApplicationDefinitionDB.csdl|res://*/Data.ApplicationDefinitionDB.ssdl|res://*/Data.ApplicationDefinitionDB.msl;
provider=System.Data.SqlClient;
provider connection string="data source=MYDBSERVERNAME;initial catalog=myDBcatalog;
User ID=myUserID;Password=myPassword;integrated security=false;
multipleactiveresultsets=True;App=EntityFramework""
providerName="System.Data.EntityClient" />
There is also an old connection string that the third party used which had integrated security set to true and reference SQLExpress, but I commented it out.
Note that I am specifying integrated security to be false (I know it's by default but I wanted to be explicit), and also supplying a username and password to the SQL Server. So why is the error message in the service ref test client saying that it's trying to connect using DOMAIN\APPSERVER$ as though it's using integrated security?
I am using IIS to host my app and SQL Server for database work. I think I have updated and re-generated all Entity Framework stuff for the database reference, but I could be missing something. Can anyone suggest anything that I may be missing to make sure the service reference uses the connection string supplied in it, and NOT the app server domain login? Thanks!
Turns out that connection string conflicted with one above the project level of the service. The project that housed the service uses Silverlight, so I thought the ClientConfig files were the only other configs being used, but there was another one hiding in the project that I published. When I rooted around in that web.config file, I found that there was a connection string with Integrated Security turned on. Once I turned that off it worked fine. That's annoying.
I have my website with hostgator and I want to access mysql database with C# windows application but when I tried to connect got this message:
"Authentication with old password no longer supported, use 4.1 style
password"
I have tried given solution:
SET SESSION old_passwords=0;
SET PASSWORD FOR user#host=PASSWORD('your pw here');
first query executed successfully but I got the error "Access denied for user#host" when second query executed. I can't understand why there is this problem. I am using MySQL-connecter-net 6.6.5.
I successfully connect my database with MySql workbench 5.2.47.
Can anyone help me what I can do more?
I have contact my hosting site and they make changes to my.cnf file to use 4.1 style password. and i am able to connect with mysql
mysql -u <username> -p <password> -h <hostname>;
but when i tried to connect with C# with mySQL connecter net 6.6.5 i again got this error.
I am using Visual Studio 2012 with MySQL connector 6.6.5 on Windows 8 64 bit. this is the code i used to connect
using MySQL.Data.MySQLClient;
private void button1_Click(object sender, EventArgs e)
{
string connStr = String.Format("server={0};port={1};uid={2};password={3};database={4}",
txtserver.Text, txtPort.Text, txtUser.Text, txtPassword.Text, txtDatabase.Text);
conn = new MySqlConnection(connStr);
try
{
conn.Open();
MessageBox.Show("Test Connection Succeded");
}
catch (MySqlException ex)
{
MessageBox.Show(ex.Message);
}
}
I can't understand where the problem is. Please Help me
I had the same problem. In my case just ran the command below connected on my database by the Workbench:
SET SESSION old_passwords=0;
SET PASSWORD FOR my_user=PASSWORD('my_password');
After that I could connnect using MySql Connector 6.6.5 in the c# code with the common mysql connection string:
"server=my_server_ip;user=my_user;database=my_db;port=3306;password=my_password;"
Today I had a similar problem in my C# application. I tried connecting to a server at hostgator.com (mysql) and connecting to localhost. After reading many posts and making many alterations, following every step but I couldn't connect to my hostgator mysql.
The solution in my case was to change the MySql Connector/NET library from version 6.* to version 5.*. After the change my application connected successfully.
While this might not be a viable solution for everyone, it may work for some.
I met this problem today, but I'v fixed it as below:
SET old_passwords=FALSE;
SET PASSWORD = PASSWORD('new pwd here');
Well, maybe the server's connection version is lower than the client, so you have to run this:"SET old_passwords=FALSE;"
Good Luck!
Had the same problem using MySqlClient package for C#. Let's break it down:
We need the database to not use old style passwords, thus we perform
SET old_passwords=0;
NOTICE there is no "SESSION" keyword. This is what allowed only your first query to work, "SESSION" implies temporary and any session settings are lost after a session ends.
Next we need to set the password of the user#host to the new password style
SET PASSWORD FOR user#host = PASSWORD('password');
This two should allow your MySqlClient
Just wanted to add to #diangelisj answer and say the root of the problem is the version of PhpMyAdmin installed on your server. In order to use the latest MySQL Data Connector class, you have to have the latest PhpMyAdmin (or issues arise). In my case, I have PhpMyAdmin 4.0.10.7 and tried using MySQL Data Connector 6.7.9, which gave the error.
What I did:
Download version 5.2.7 from https://dev.mysql.com/downloads/connector/net/6.9.html
Add .dll as reference to application
Presto!
Forget about applying SET old_password=0 since if the server is configured to use new password there is no reason to change the flag on the server if your app does not access anymore. Investigate the connector NET that you are using.
Connector 6.5.4 is the right one to use old_password, rencent version are using the new one.
The best practice would be to avoid to install the connector on the machine, just leave the NET to handle the dll if you already have it or anyway try to find MySQL.Data.DLL version 6.5.4.0 (384 kbytes)
I just solved my problem just like this:
1) Connect to the db with mysql workbench (select the "use old auth" and "send pass in cleartext"
2) Using the workbench, I ran the following several times (because it kept saying '0 rows affected'): (also change userID and password to your proper stuff)
SET SESSION old_passwords=0;
SET PASSWORD FOR userID=PASSWORD('password');
SET SESSION old_passwords=false;
SET PASSWORD FOR userID=PASSWORD('password');
3) Now go back to your app and it should run...
That is how I did it at least. I am using IX mysql and they do use old auth on their server so you must do something on your end...
I have not managed to solve the problem as the others who have responded, although I tried out everything that has been proposed.
In the end it turned out that the server on which stood my DB is not updated phpMyAdmin since version 3.5.5, and is currently being used everywhere version 4.1.14 and it is a problem.
The solution is to update your host phpMyAdmin or your own mySQL back to an earlier version in order to continue working on remote DB.
You may need this knowledge in order to solve some doubts that have arisen. :)
Today I found the same problem. I downloaded Workbench. There are some settings for workbench to connect database, as follows:
1.select tab SSL , select option 'no' in "Use SSL".
2. select tab advanced, select in Use the ole authentication Protocol.
after that Workbench working.
and follow tai1001' post.
That are all I found all steps that work.
I was trying out making a website with asp.net to see how data binding works but when I launch the application, it throws this 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.
I checked the internet and I found a lot of possible solutions but none of them worked for me.
I created a custom database in the App_Data folder of the project and the connection string is
Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True
It cannot locate the data file at the specified path, or the user does not have sufficient privileges to access the data file.
If the database is set up for Windows Authentication Mode, you should try changing your connection string to something like this:
Server=<COMPUTER NAME>\SQLEXPRESS;Database=<DATABASE NAME>;Trusted_Connection=True;
OR
Server=<COMPUTER NAME>\SQLEXPRESS;AttachDbFilename=<DIRECTORY PATH>\<FILE NAME>.mdf;Trusted_Connection=True;