Connect to Deprecated Sybase Database - c#

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.

Related

ASP.NET MVC C# change code from accessing a mySQL database to a MSSQL database

I have an application that I used to connect to a mySQL database. I have installed the MySQL.Data package and I use this code to build my connection:
services.AddScoped<System.Data.IDbConnection>((s) =>
{
IDbConnection conn = new MySqlConnection(Configuration.GetConnectionString("databasename"));
conn.Open();
return conn;
});
This works fine as I am able to read/write data from the database.
Now, I need to have the same application access a MS SQL database. The tables are all the same and the fields on each table are the same as well. I am having a hard time finding what I should change my code to (or what package I should include). When I remove the MySQL.Data package, the MySqlConnection function becomes invalid (as would be expected).
Any idea what package to include and what function to use to establish the connection?
Any assistance is greatly appreciated.
Thank you!
EDIT #1
I found an old stackoverflow post (I should have referenced it here but I closed the window) that talks about this very issue. The suggestion was to add
using System.Data.SqlClient;
and then change the assignment code to
IDbConnection conn = new SqlConnection(Configuration.GetConnectionString("databasename"));
I made these changes and now I get this error within the code:
Im at a loss as to how to resolve this. I verified that my project is in framework .NET core 3.1
Not sure about size of your project and detailed requirements but I would suggest to use libraries like:
Entity Framework - no SQL knowledge needed, can connect to any Db technology, almost no code changes required when switching between Db providers
or
Dapper - fast lightweight also supports multiple Db providers but you need to write correct SQL commands yourself specific for each Db technology you use

System.Data.OleDb.OleDbException: 'Could not find installable ISAM.' - MS Access (.accdb) and C# (.Net Framework)

There were few similar questions here, but i couldn't locate any with acceptable answer. or that it would actually work one.
I have create a local storage as .accdb file and tried to connect witch c# to it.
In summary those are the parts needed:
public static string accessConnectionString = #"Provider=Microsoft.ACE.OLEDB.12.0;DataSource=C:\MS_Access_Test_DB.accdb";
OleDbConnection connection = new OleDbConnection(accessConnectionString);
connection.Open();
It always crashes, with an error from description. I had tried to use apostrophes, quotes etc for C:\MS_Access_Test_DB.accdb
I had also tried JET.4.0 with same error & adding Persist Security Info=True; into the mix.
Ok,
The issue as pointed out by Steeeve & Panagiotis Kanavos using is access driver 32bit when i use 64bit architecture, and this will not work. Especially in office/corporation that already has a lot of build in add-ins for office 32 bit. There is also workaround, to install both drivers, but it would require each user to have it, therefore it wasn't solution in my case.
Id much prefer using SQLite, but the tables have to be connected to PowerBI i now that SQLite have to use external drivers to update datasets, therefore for now, this solution was also out.
Considering I cannot force each user to change drivers etc. I tried and saved the access file as .mdb (2002-2003).
So it's either: intalling 64bit driver (proposed initialy) or a workaround (with .mdb):
public static string accessConnectionString = #"Provider=Microsoft.JET.OLEDB.4.0;Data Source=C:\MS_Access_Test_DB.mdb";
OleDbConnection connection = new OleDbConnection(accessConnectionString);
connection.Open();
Or:
public static string accessConnectionString = #"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\MS_Access_Test_DB.mdb";
OleDbConnection connection = new OleDbConnection(accessConnectionString);
connection.Open();
Important note, there is lot of .accdb functionalities that cannot be used in .mdb, so if you have to use access, than be carefull. If you can, consider SQLite/SQL SE proposed in comment's under my question.
EDIT: I had also messed up the first time... Instead of DataSource I should have had Data Source so it seems to work, despite using Driver 32bit against 64bit app.

Local DB in Visual Studio 2015

After a few years, I have returned to writing in C# and I am really struggling here - I would like to have my app to have a local SQL database. I have added Service-based database and "Database1.mdf" was added to my project. I created a table and added some data just to see if it is working but I cannot connect to it. I tried numerous connection strings with no success (Server not accessible).
Do I need to run something else in the background? I thought that I might have a local database and with .NET client I can access it, and I hoped it would work whenever I bring my application (also not requiring any SQL server running). Is that wrong?
If you don't require any SQL server, take a look at SQLite. This is lite SQL database engine. Database is just one file. C# has a great library to SQLite on NuGet: https://www.nuget.org/profiles/mistachkin
SQLite is widely used, event in Android (as a native db engine).
here is what i use to connect. it appears as a Data Connection in Server Explorer.
string con2 = #"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=" + Application.StartupPath + "\\jobfile_2017.mdf;Integrated Security=True;Connect Timeout=30";
when i first started working with these, i used this source 1
it works on PC's that i have nothing installed (not even office) but as i said i'd be interested to know of any shortcomings of this method
I experiencing same problem and decided to move mdf file to static c:\db directory. Connection string was changed to incorporate new file location (AttachDbFile).
But AttachDbFile has some issues also (by some reason one table in db is inaccesible and error is access denied).
So I decided to move to Sqlite. LocalDb has many issues to work with. I read good note to resolve problem: in command line stop/remove/start name of instance. But it nuissance.
Wish you good luck to work with these db files.

Firebird 1.5 / Asp net VS 2010 (legacy database .CDB extension)

I have an old system which generated me a database in .CDB extension (i run on Firebird-1.5.6.5026-0-Win32) and i can access this database in IBExpert to query and stuff. But i need to write an application in .NET (VS 2010 4.0 framaework) so i can read this database and access some of the data to insert into a table inside SQLServer.
I tried many things, changed the server version and other things but i now all i get is ''Cannot find fbembed.dll'' exception error while trying to open the connection. My FB server doesnt have this file since he uses the 'fbclient.dll' already.
Any thoughts on how to connect my application to this .CDB database?
(this firebird version is the same that the legacy system is running, so i used the 1.7RC firebird .net provider within this server)
The connection string used is:
<add name="FirebirdConnectionString" connectionString="User=SYSDBA;Password=masterkey;
Database=localhost:C:\temp\BD\E‌​CLECTIC.CDB;DataSource=localhost;Port=3051;
Dialect=3;Charset=NONE;Role=;Connectio‌​n lifetime=15; Pooling=false;
MinPoolSize=0; MaxPoolSize=50; Packet Size=8192; ServerType=1;"
providerName="FirebirdSql.Data.FirebirdClient"/>
Unless you really want to use Firebird embedded (which you don't as you also specify localhost), you should not specify ServerType=1, but either leave it out entirely or set ServerType=0.
As to your other problem you mention in the comments, I suggest you check if this solves it and otherwise create a new question with more information.

Can't connect to Oracle database

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

Categories

Resources