Oracle 9i: ORA-01017: invalid username/password; logon denied - c#

I get the following exception when I try to connect to my Oracle 9i database from my Visual Studio 2017 application:
ORA-01017: invalid username/password; logon denied
Code:
var connectionString = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=myServerName)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SID=mySID)));User Id = myUsername; Password = myPassword";
var con = new OracleConnection(connectionString);
con.Open();
Same problem when :
using same code with System.Data.OracleClient assembly
trying to add a new Data Connection via Server Explorer in Visual Studio.
I tried setting System\CurrentControlSet\Control\Lsa\FIPSAlgorithmPolicy\Enabled to 0 with no luck.
When I use SQL Developer I am able to connect to the same database with same credentials and perform any query.
Any idea ?
Database: Oracle 9i
Visual Studio : 2017

I found the answer.
remove any associated plugin in Visual Studio
execute uninstall.bat from your ODAC downloaded folder
remove any associated tool in Windows Add or Remove Program
Remove remaining Oracle folders (in C:\, C:\ProgramFiles, ...)
Make sure there is no remaining Oracle reference in GAC, otherwise delete them.
The latest compatible version of Oracle provider is Oracle version + 2 (9+2=11), meaning the maximum version I had to install was 11.2.0.4. After installing this version and compile my code in x64 (Any CPU or x32 won't load the DLL) evrything was working.

Related

C# application deployment issue with .mdf database

I am working on a C# database application for learning and I'm trying to deploy it on client machine and getting connection problem.
//NOTE: path and database variables have correct info because it works on my dev machine
"Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=" + path + "\\" + databaseName + ";Integrated Security=True"
I am using Install Shield for creating setup and tried Advance Installer also.
On the other test machine I have installed:
.Net Framework 4.5.2
SQLLocalDB.msi (x64 bit)
Lastly, I installed my deployed setup file and I was getting an Exception:
System.Data.SqlClient.SqlException (0x80131904). A network related or instance-specific error occured while establishing a connection to SQL server.
The server was not found or not accessible.
Localdatabase Runtime error occured.
I also tried these in Connection String: (found in similar question on stackoverflow)
localhost
localhost\\SQLExpress
.\\SQLExpress
But none of this work for me.
NOTE:
My LocalDB connection string is working on dev machine.
Using Visual Studio 2015 Enterprise
PS: What I am trying to learn is a way to create an installer which installs some per-requeisites like .Net Framework, LocalDB etc and can run database based application on client machines without installing SQL Server separately. I am not sure if the .mdf way is the good fit for this or not.
I would suggest you to use SQLite Database because the process and function are almost similar. And the deployment is super easy; it just requires few DLLs to make it work.
Guideline:
First you will need System.Data.SQLite library and then needs to add System.Data.SQLite.dll as a reference in your project. Keep in mind that SQLite.Interop.dll also needs to be in your executables directory but doesn’t need to be added as a reference in your project.
Moreover, if your application is targeting Any CPU it is likely that you will get an exception. So make sure to navigate to Project properties -> Build and set the Platform target to the bit version of the System.Data.SQLite.dll binary you have downloaded.
As you are beginner so here is the step by step guideline along with sample code.
Steps:
Navigate to: Tools > NuGet Package Manager > Manage NuGet Packages for Solution
Search For: SQLite
Select System.Data.SQLite (would be first result)
Click on Install
Import library
using System.Data.SQLite;
The connection is ready and here is the Sample Code:
System.Data.SQLite.SQLiteConnection.CreateFile("sqlite.db3");
using(System.Data.SQLite.SQLiteConnection conn = new System.Data.SQLite.SQLiteConnection("data source=sqlite.db3")){
using(System.Data.SQLite.SQLiteCommand cmd = new System.Data.SQLite.SQLiteCommand(conn)){
conn.Open();
cmd.CommandText = #"CREATE TABLE IF NOT EXISTS
[persons](
[id] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
[name] VARCHAR(50) NULL
)";
cmd.ExecuteNonQuery();
cmd.CommandText = "INSERT INTO [persons] (name) values('Atlas')";
cmd.ExecuteNonQuery();
cmd.CommandText = "SELECT * FROM [persons]";
using(System.Data.SQLite.SQLiteDataReader reader = cmd.ExecuteReader()){
while(reader.Read()){
MessageBox.Show(reader["name"].ToString());
}
conn.Close();
}
}
}
Tips:
always use try/catch block for database operations
If you don't prefer to use NuGet Package Manager then you can download library from here
Hope this helps! :)
Does one of these help?
Attach a database file on connect to a local SQL Server Express instance
Server=.\SQLExpress;AttachDbFilename=C:\MyFolder\MyDataFile.mdf;Database=dbname;
Trusted_Connection=Yes;
Attach a database file, located in the data directory, on connect to a local SQL Server Express instance
Server=.\SQLExpress;AttachDbFilename=|DataDirectory|mydbfile.mdf;Database=dbname;
Trusted_Connection=Yes;

cannot access IBM Netezza server from C# VS2013 but worked well in IBM Aginity workbench

I am trying to access a Netezza server from C# .net 4.5 VS2013 on win 7.
using System.Data.Odbc;
string connstring = "Driver={NetezzaSQL};Server=MyServerIP;Database=MyDBName;Uid=MyID;Pwd=myPWD;ReadOnly=true;";
using (OdbcConnection conn = new OdbcConnection(connstring))
{
conn.ConnectionTimeout = 120;
conn.Open(); // error 08001
Console.WriteLine("OK");
}
An unhandled exception of type 'System.Data.Odbc.OdbcException' occurred in System.Data.dll
Additional information: ERROR [08001] Client unable to establish connection
From https://msdn.microsoft.com/en-us/library/ms715433%28v=vs.85%29.aspx, I see that error 08001 is
The driver was unable to establish a connection with the data source.
From control panel --> adm tools --> Data Sources (ODBC), I checked that I have installed
NetezzaSQL 7.01.00.3553
It should be 64 bits, because there are no NetezzaSQL driver in Data Sources (ODBC - 32bits).
My C# code is built for Any CPU. Although I changed the build to 64 bits, I got the same error. It seems that C# code cannot find the driver ?
I can access the same server and DB from IBM Netezza Aginity workbench with the same ID and password without any problems.
Any ideas ?
UPDATE
I can access the same server and database with same Uid and Pwd from the server explorer in VS2013. But, why I cannot access it from C# code ?
In server explorer, I right-clicked the connected server and in "Modify Connection" window, I copied the "use connection string" into my C# code.
But, it does not work!
NEW UPDATE
Also, I have used the same string by calling the package of "pypyodbc" in Python 3.4.1 (32 and 64 bits) on the same machine, it worked well.
It means that the nsqlodbc.dll lib of 32 and 64 bits have no problem.
I guess the problem is at C# or VS2013.
Also, in VS2013 server explorer, it can only accept 32 bits nsqlodbc.dll and establish the connection. For example, if I only installed 64 bits nsqlodbc.dll, the server explorer cannot connect the Netezza server either.
Try this connection string:
Driver=NetezzaSQL; Server=MyServerIP; Port=5480; Database=MyDBName; Persist Security Info=true; UID=MyID; PWD=myPWD

error in connection c# with oracle 11g 64 bit machine?

My c# form has an error in the connection from c# with oracle 11g express edition, I've put my connection string in app.config file. This is my connection string:
add name="ConnectionString" connectionString="Provider=MSDAORA;Data Source=localhost;Password=LIB314;User ID=LIB_DB" providerName="System.Data.OleDb"
When I want to run a query, it gives me error saying
The 'MSDAORA' provider is not registered on the local machine
I use Windows 8.1 Pro x64... Can anyone please help me?
UseORAOLEDB.ORACLE rather than MSDAORA.
Check below URL
https://community.oracle.com/thread/1022162
Thanks
Nipun
Try using OraOLEDB instead of MSDAORA. Register OraOLEDB11.dll using regsvr32.exe.
To do so, open command prompt and browse to the BIN folder of under your Oracle HOME's installation path (probably oracle\product\11.2.0\dbhome1\BIN) and execute the following line:
>regsvr32.exe OraOLEDB11.dll
Also, ensure verify that the PATH variable is set properly and points to Oracle's installation path i.e.: C:\oracle\product\11.2.0\dbhome1\BIN

this is error ORA-12154: TNS:could not resolve the connect identifier specified?

I've this code :
OracleConnection con = new OracleConnection("data source=localhost;user id=fastecit;password=fastecit");
con.Open(); string sql="Select userId from tblusers";
OracleCommand cmd = new OracleCommand(sql, con);
OracleDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{ messageBox.Show(dr[0].Tostring()); }
Same code in both projects,
in project1 "WinForm" Is Working correctly
in project2 "Excel 2007 addins" Following error appears:
ORA-12154: TNS:could not resolve the connect identifier specified
I'm using C#.net 2010 ,office 2007 , windows8, oracle 10g.
When preparing a manual connection to the database, as shown in the picture
Visual Studio, open View menu + Server Explorer.
Right mouse click on Data Connection + Add Connection + Select Oracle Database
server Name : localhost or name of my machine, set username & password and click on Test Connection, test is no succeeds.
ORA-12154: TNS:could not resolve the connect identifier specified?
In case the TNS is not defined you can also try this one:
If you are using C#.net 2010 or other version of VS and oracle 10g express edition or lower version, and you make a connection string like this:
static string constr = #"Data Source=(DESCRIPTION=
(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=yourhostname )(PORT=1521)))
(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=XE)));
User Id=system ;Password=yourpasswrd";
After that you get error message ORA-12154: TNS:could not resolve the connect identifier specified then first you have to do restart your system and run your project.
And if Your windows is 64 bit then you need to install oracle 11g 32 bit and if you installed 11g 64 bit then you need to Install Oracle 11g Oracle Data Access Components (ODAC) with Oracle Developer Tools for Visual Studio version 11.2.0.1.2 or later from OTN and check it in Oracle Universal Installer
Please be sure that the following are checked:
Oracle Data Provider for .NET 2.0
Oracle Providers for ASP.NET
Oracle Developer Tools for Visual Studio
Oracle Instant Client
And then restart your Visual Studio and then run your project ....
NOTE:- SYSTEM RESTART IS necessary TO SOLVE THIS TYPES OF ERROR.......
The database must have a name (example DB1), try this one:
OracleConnection con = new OracleConnection("data source=DB1;user id=fastecit;password=fastecit");
In case the TNS is not defined you can also try this one:
OracleConnection con = new OracleConnection("Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=DB1)));
User Id=fastecit;Password=fastecit");
run the below command in command prompt
tnsping Datasource
This should give a response like below
C:>tnsping *******
TNS Ping Utility for *** Windows: Version *** - Production on *****
Copyright (c) 1997, 2014, Oracle. All rights reserved.
Used parameter files:
c:\oracle*****
Used **** to resolve the alias
Attempting to contact (description=(address_list=(address=(protocol=tcp)(host=)(port=)))(connect_data=(server=)(service_name=)(failover_mode=(type=)(method=)(retries=)(delay=))))**
OK (**** msec)
Add the text 'Datasource=' in beginning and credentials at the end.
the final string should be
Data Source=(description=(address_list=(address=(protocol=tcp)(host=)(port=)))(connect_data=(server=)(service_name=)(failover_mode=(type=)(method=)(retries=)(delay=))));User Id=;Password=;**
Use this as the connection string to connect to oracle db.

Connecting to an oracle database in C# .Net

Hi I use the following code to connect to an orace database in Visual Studio 2008 and it is falling over with the exception of ServerVersion threw an invalid operation exception at line 3:
m_strConnectionString = Settings.GetMandatoryConfig("databases", "SourceDB");
m_strQueryTerminator = Settings.GetConfig("databases", "QueryTerminator");
m_odbConn = new OleDbConnection(m_strConnectionString);
m_sql = new SQL(DatabaseType.AnsiSQL, false);
m_strConnectionString is a valid TNS names connection string and is as follows:
Provider=MSDAORA;Data Source=myDS;User
ID=myID;Password=myPW
This has previously worked and is using an IIS web server to host the application. I recently converted it from .Net 1.1 (VS 2003) to .Net 3.5/2 (VS 2008) and can't get it working as yet in VS 2008.
Thanks
Maybe you should consider using the OracleConnection class instead of the generic OleDbConnection. Doing this may give you more specific error information that what you're receiving now - and could help you find your problem quicker.
See here for more information on the System.Data.OracleClient namespace included with the .Net framework.

Categories