Creating OdbcConnection to relativity client - c#

I went through the process of creating the server and client ODBC objects in my computer to a Cobol database and I named the client PARSECCLI.
I tested the connection and it works. I can get datasets through Microsoft Query (I can't get Sql Server Management Studio to connect to it as a Linked Server or anything, but that's a separate question).
I can also create, through Visual Studio's wizard, a Datasource connection to it and the connection test succeeds. It creates this connection string:
Dsn=PARSECCLI;uid=.;codepage=1252
However, if I try to create an OdbcConnection to that string and open it - my end goal is to be able to run queries on the database and pull datasets from it - I get this:
System.Data.Odbc.OdbcException (0x80131937): ERROR [IM014] [Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application
if I take advice from This question and change my connection string to this:
OdbcConnection dbConnection = new OdbcConnection("DRIVER={Relativity Client};ServerName=192.168.0.109.1583;DSN=PARSECCLI;UID=.;codepage=1252"); //The local IP I set to static when I created the client and server odbc Data Sources.
I get:
System.Data.Odbc.OdbcException (0x80131937): ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
Should I be using a different sort of Connection type or am I missing something from my connection string/s?

The ODBC Administrator (odbcad32.exe) program comes in two versions on 64bit systems. The default one (the one present in the Administrative Tools) is the 64bit version and creates DSN names usable by 64bit programs (or AnyCPU programs that runs on 64 bit OS).
If you want your DSN usable by a 32 bit program create it with the ODBC Administrator available in the c:\windows\SysWOW64 folder.
Of course your application should use the appropriate Target CPU through BUILD -> Configuration Manager, Active Solution Platform.
Sadly I have no answer for the second issue but I hope that the first one is enough to allow you continue on your program

Related

SQL Server network interfaces error 52- Unable to locate a database at runtime installation

I am creating a POS system in Windows Forms (C#) in which I use a SQL Server database file (.mdf) to store items (completely offline). When I install the application on my computer, it works fine, but when I install it on my clients PC, an error happens:
(provider: SQL Network Interfaces, error: 52 - Unable to locate a Local Database Runtime installation"
I read somewhere that the problem is caused due to the fact that the connection string of the database of my client's PC is different. I tried to add the connection string dynamically on runtime but again it only worked on my computer.
Another reason that might be causing the problem is that I used 'server-based database' since local database option isn't available in Visual Studio 2017 for some reason.
Another solution I looked up stated that I should install SQL Server Express on my client's PC. That also failed (maybe I have to set it up in a way or something).
I also tried adding the database.mdf and database_log files in the setup folder.
Lastly I tried installing 3rd party installers (Advanced installers 15.8 and InstallShield Wizard in VS 2015) which also failed.
(I have provided the code for the connection of database taking place and the connection string)
public void ConnectToDB()
{
DBConnection = new SqlConnection(#"Data Source = (LocalDB)\MSSQLLocalDB; AttachDbFilename=C:\Users\SAIM NASSER\Desktop\app layer\data layer\Database1.mdf; Integrated Security = True");
DBConnection.Open();
ResultSet = new DataSet();
}
If I understand you correct, you want to use LocalDB
That means using Sql Server without installing a full sql server, but just the localdb part from sql server express.
For this to work you need to install the LocalDB Driver, which can be found here
https://www.microsoft.com/en-us/download/details.aspx?id=29062
You need only the ENU\x64\SqlLocalDB.MSI
This is the only thing you need to install in your clients computer, I believe it can also be installed silent, you have to research a bit for that.
And yes, you also should change the connection string on the clients computer, you need to alter it so it points to the MDF file on the clients computer, because that location will probably be different then on your computer
EDIT
To get the connection string working, you can try this
On the clients computer, create a text file and rename the extension to .udl
So for example you have a file test.udl
Now from explorer, double click it, this will open the datalink editor.
From here you can enter/choose different settings, and click on the test connection button.
Once you get a working connection, save it, and open this file with notepad.
Inside you will find the working connection string
Hope this helps

Data source name not found and no default driver specified when reading mdb file in 64 bits OS from 64 bits app:

I have a ASP.NET MVC application (64bits) running in a 64 bits Windows system (Windows Server 2012).
My web application needs to read a mdb database, then I created the next code:
using (var myConnection = new OdbcConnection())
{
try
{
string myConnectionString = #"Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=" + fileNameWithPath + ";Persist Security Info=True";
myConnection.ConnectionString = myConnectionString;
myConnection.Open();
OdbcCommand cmd = myConnection.CreateCommand();
cmd.CommandText = "SELECT * FROM myTable";
OdbcDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
// Load the result into a DataTable
myDataTable = new DataTable();
myDataTable.Load(reader);
}
catch (Exception exception)
{
//nexy exception is caught here: "ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified"
}
finally
{
myConnection.Close();
}
}
Where fileNameWithPath is the path of the mdb file.
When I execute the code above, I have the next annoying exception in the line
myConnection.Open();:
ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not
found and no default driver specified
I've checked the server and it has the next files installed regarding ODBC driver:
File odbcad32.exe under the folder C:\Windows\System32
File odbcad32.exe under the folder C:\Windows\SysWOW64
My question is: Is my server setup correct? Do I have the 64 bits version of ODBC really installed?
and more important: Can I run a x64 application in x64 server with such configuration? Otherwise, is there any other alternative? It is worth to mention that:
I'm not allowed to install additional software in the server
The web application must be 64 bits
Thanks in advance.
To use the x32 bit version of the Access database engine, then you will require an x32 bit version of the database engine installed on that computer.
And to use the x64 bit version of the Access database engine, then you require an x64 bit version of the Access database engine to be installed.
And hey, if you need to read an oracle database, then lo and behold, you need the oracle database engine installed to read oracle files that reside on the disk drive.
If you can’t install any additional software such as oracle to read oracle files, or SQL server to read sql server files, or in this case Access, then you are duck soap. And really, to read PDF files, then you need some PDF file software installed.
So unless you can get around the issue of not being allowed to install the appropriate software on your server, then you not going to be able to read the given files that such software consumes – this applies to near EVERY software system - you need to install the appropriate software on that server to enable use of such files.
So there does exist both an x32 and x64 bit version of the Access database engine (ACE), and unless you are allowed to install such software then you can’t read and consume such data.
So keep in mind that when developing software, if you want to open a word file, or pdf file or like any software system you will require the apocopate software to be installed to work with such files – Access is no exception. If you need to open a power point file, then it becomes obvious that you need power point software installed on that computer.
So you need to obtain and install the x64 bit version of the Access database engine on that server. And since you note you can’t install any software, then you are unlikely to achieve your goal.
I resolved a very similar issue by enabling 32-bit applications in the advance settings of the application pool in IIS

Connecting to MYSQL error

My code is wrote in C#
I have a problem while connecting to MYSQL remote DB .
The remote DB is 64 bit while the one in local system is 32bit.
The one in 32bit works, the one in remote doesn't.
Im using this version of drivers : " DRIVER={MySQL ODBC 5.3 ANSI Driver}; ", one in 32bit , the other one in 64bit (remote one)
This is the error i got :
System.Runtime.InteropServices.COMException (0x80004005):
[Microsoft][ODBC Driver Manager] Data source name not found and no
default driver specified
Anyone has any ideas to deal with this?
Thanks

Errors connecting to an offline cube (.cub) file

I've been searching for a solution to my doubt but couldn't find anything more relevant than an installation issue, which isn't a problem in my case.
I am trying to execute a C# project (similar to this) that creates a local cube (.cub) file and processes data taken from an existing processed cube on Analysis Services 2012.
The project runs correctly when I use a connection string for output cube that points (and hence writes) to another database on Analysis Services. But when I execute the project using the following connection string that points to the local cube file to be created, it gives me errors depending on the version of ADOMD library referenced.
conn.ConnectionString =
string.Format( "Provider=MSOLAP;Data Source={0}", "c:\\output\\mycube.cub" );
When referenced to ADOMD 11 library, I get the following errors:
OLE DB error: OLE DB or ODBC error: A network-related or instance-specific error has occurred while establishing a connection
to SQL Server. Server is not found or not accessible. Check if
instance name is correct and if SQL Server is configured to allow
remote connections. For more information see SQL Server Books Online.;
08001; Client unable to establish connection; 08001; Encryption not
supported on the client.; 08001.
Errors in the high-level relational engine. A connection could not be made to the data source with the DataSourceID of 'DB_NAME', Name of
'DB_NAME'.
When referenced to ADOMD 12 library, I get the following error:
A connection cannot be made. Ensure that the server is running.
Although, I know SQL Server Analysis Services are running when I checked in services.msc.
Figured it out. I was missing a reference to the assembly Microsoft.AnalysisServices.dll

MYOB ODBC connection error

I recently got a prebuild application which is uses a MYOB ODBC connection to a MYOB file.
The ODBC connection works perfectly in that application.
I'm using the same ODBC connection string in another application but it failed to open in that application. The connection string is perfectly identical but it won't work there.
The error I'm getting is:
ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
The server explorer in Visual Studio 2008 connects without a problem with the same connection string.
Is it a trusted application issue because my new application is not digitally signed at the moment?
OdbcConnection odbc = new OdbcConnection("Driver=MYOAU0901;TYPE=MYOB; UID=Administrator; PWD=; DATABASE=C:\\Premier125\\Clearwtr.MYO; NETWORK_PROTOCOL=NONET; DRIVER_COMPLETION=DRIVER_NOPROMPT;;KEY=****");
odbc.Open();
The key used in the connection string is definitely valid.
kindly help me.
MYOB ODBC does not require your application to be signed. The company file must be registered for ODBC to allow reads, and you must install a licence key to allow writes. I am assuming your new application is running on the same machine as the company file and MYOB executable, and that your company file is properly registered.
Try setting the KEY parameter to the key itself, not a path to a key file.
Replace ;; with ;
Include the key HOST_EXE_PATH in your connection string. This is the path to the MYOB executable (in your case this will be myobp.exe).
If you still have no luck, try setting up a User DSN. This will allow you to test whether everything is installed correctly. If the DSN works, you can try replacing your connection string with a reference to the DSN, so "DSN=YourDsnName".

Categories

Resources