I am working on application which uses Sybase database and entity framework for accessing database. I am trying to make application to open connection itself and close it. I created model using Sybase database file and now connecting to it to get data. But when I try to get data I get exception "The underlying provider failed to Open".
Here is my code.
var connectionString = metadata=res://*/SampleModel.csdl|res://*/SampleModel.ssdl|res://*/SampleModel.msl; +
provider=iAnywhere.Data.SQLAnywhere; +
provider connection string="DBF=D:\SampleDatabase.db;UID=DBA;PWD=sql"
var dataContext = new SampleContext(connectionString);
var contacts = dataContext.Contacts; --> Here I get this exception.
Note: If I create a DSN in ODBC and use DSN instead of giving filename it gives me Not connected to a database exception. If I open this connection and do not close it, then it works fine. But I don't want to create DSN entry and open it manually. I want my program to do this.
There was problem with my version of Sybase. I was using 3840 build of Sybase 12. I removed it and installed 3769 version and it worked fine. On different forums I found out that latest (3840) is having problems.
Related
I am attempting to connect to an IBM DB2 database from a .NET 5 console application. This works fine against DB2 LUW in a local Docker instance, but fails when connecting to a z/OS mainframe instance.
Server:
IBM DB2 v11.5
z/OS
Client:
.NET 5 console application
IBM.Data.DB2.Core (v3.1.0.400)
IBM Data Server Driver (v11.5)
Error:
IBM.Data.DB2.Core.DB2Exception (0x80004005): ERROR [57017] [IBM] SQL0332N Character conversion from the source code page "" to the target code page "" is not supported. SQLSTATE=57017
at IBM.Data.DB2.Core.DB2ConnPool.Open(DB2Connection connection, String& szConnectionString, DB2ConnSettings& ppSettings, Object& ppConn)
at IBM.Data.DB2.Core.DB2Connection.Open()
at <my code>
Connection string:
Database=<redacted>;User ID=<redacted>;Password=<redacted>;Server=<redacted>:448;Persist Security Info=True;CurrentSchema=<redacted>;Connect Timeout=30
Opening connection:
var connection = new DB2Connection(connectionString);
try
{
connection.Open();
}
catch (DB2Exception e)
{
logger.LogError("Unable to access DB2 instance");
logger.LogError(e.ToString());
throw new DbAccessAcception(e);
}
The DB user I am testing with is already in use by another .NET program to connect to this database, though that app is older (.NET Framework 3.5).
What I've tried:
Setting the code page to 1200, 1208, or 1252, using both the DB2CODEPAGE environment variable as well as the connection string CodePage parameter; nothing changed the error message
Verified all software (DB2, DB2 DSDRIVER, .NET provider) are v11.5
Verified I can connect and run queries with db2cli.exe
Now what?
Is there somewhere I can/should be setting the DB2 server type? Eg, z/OS vs LUW? Note that I'm not using EntityFramework, just directly executing Commands on that Connection object (though the error comes before then).
We have solved the problem. There were two changes to make, which definitely complicated things.
We did need to set the DB2CODEPAGE environment variable to 1208
We were using the CurrentSchema connection string parameter to set the prefix for our SQL queries, but the prefix wasn't the actual schema, which broke the connection even when the right codepage was set, without a useful error message on the client. We removed that parameter and manually set the table prefix on our SQL queries.
Making both those changes got the application working.
Connecting to the local Docker instance had worked because I had set an actual schema for that prefix, not realizing the prod instance was configured differently.
I'm trying to connect to a Sybase Adaptive SQL Anywhere database that is running version 9. I'm currently trying to use iAnywhere.Data.AsaClient.dll. When I try to create a new connection,
AsaConnection myConnection = new AsaConnection();
I get System.IO.FileNotFoundException stating File dbdata9.dll was not found.
I can't find dbdata9.dll anywhere and it seems as if Sybase has long since deprecated that version. Is there anyway to get this file or are there any other tools that I can use to get access to this data programmatically?
I used Java instead, following this article with a few modifications. I have access to jconn4.jar so I was able to add that as a reference.
I am a beginner in working with databases. I am trying to access Oracle10g database from a c# application. But when I do so i get this error:
ORA-12154: TNS:could not resolve the connect identifier specified"
I'm using the following code:
string oradb = "Data Source=ORCL;User Id=system;Password=goodbye;";
OracleConnection conn = new OracleConnection(oradb); // C#
conn.Open();
Is there an error in the connection string oradb?
Start the Visual Studio, open View menu + Server Explorer.
Right mouse click on Data Connection + Add Connection + Select Oracle Database
server Name : localhost or name of your machine, set username & password and click on Test Connection to verify the above parameters. Press OK if test is succeeds.
From properties windows you can obtain connection String and it should be look a like:
Data Source=localhost;Persist Security Info=True;User ID=scott;Password=***********;Unicode=True
Oracle is just stating that it can't find the database.
If you're running a local Express Edition database, you should be able to just use XE as an instance name, and everything should already be set up, otherwise you can most easily add it to tnsnames.ora.
To find the correct tnsnames.ora to change, you can try (from the command prompt)
tnsping ORCL
That will tell you which files Oracle is using to try to find the database. If tnsping is an unknown command, you may have to search for it and go to the correct place before running it.
One you found the correct tnsnames.ora, you need to add the instance ORCL to it. There should be an existing file with examples, the syntax of that file is too complex to answer here, if you need help, Oracle has quite extensive documentation.
This is a very common oracle error. Simply put, it means that you have named the database you wish to be connected to and Oracle doesn’t know who the heck you’re talking about. I suggest 6 Steps to fix ORA-12154:
Check instance name has been entered correctly in tnsnames.ora.
There should be no control characters at the end of the instance or database name.
All paranthesis around the TNS entry should be properly terminated
Domain name entry in sqlnet.ora should not be conflicting with full database name.
If problem still persists, try to re-create TNS entry in tnsnames.ora.
At last you may add new entries using the SQL*Net Easy configuration utility.
More informations on oracle site or here : http://turfybot.free.fr/oracle/11g/errors/ORA-12154.html
I am working on an ASP.NET project, which uses C# for code-behind. It attempts to connect to an Oracle database using the following code, which already existed in the project when I began working on it:
OracleConnection myConnection = new OracleConnection();
myConnection.ConnectionString = ConfigurationManager.ConnectionStrings["OraFinCnString"].ConnectionString;
myConnection.Open();
The application runs locally (opens up in a browser on localhost), and attempts to connect to a remote Oracle Database. When I run it, the The last line above gives the following error:
"InvalidOperationException was unhandled by user code. Attempt to load Oracle client libraries threw BadImageFormatException. This problem will occur when running in 64 bit mode with the 32 bit Oracle client components installed."
The connection string was provided by my client, so I presume it is correct, and this doesn't seem like the sort of error that would be caused by incorrect connection information. But I'm pretty well stumped as to exactly what the problem is, and would appreciate any insight.
Please take a look at the following link. You will need to Install Oracle 11g Oracle Data Access Components
Oracle Provider
I have an application with a database called voodoobase.sdf.
Using .NET Framework Data Provider for Microsoft SQL Server Compact 3.5
I can see it in Server Explorer and connect to it fine from there. The DB File is located in:
c:\Users\me\Documents\VisualStudio2010\Projects\testproj\voodoobase.sdf
The same named DB under Solution Explorer is said to reside at the same location.
c:\Users\me\Documents\VisualStudio2010\Projects\testproj\voodoobase.sdf
Assuming they are the same... why can my application which compiles successfully alwways crash with a connection error:
SqlConnection dbCon = new SqlConnection(Properties.Settings.Default.voodoobaseConnectionString);
dbCon.Open();
Throws an error on dbCon.Open() saying that could not get a connection to the SQL server. Let me know if further detail is required.
Do not use the SqlConnection class, but the SqlCeConnection class.