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".
Related
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
I am setting up an database application to be database agnostic, and when testing with postgresql I get the standard dsn error:
[IM002] [Microsoft][ODBC Driver Manager] Data source name not found
I usually use SQL server and MySQL so I'm new to postgres, I tried the standard recommended Connection string:
"Driver = {PostgreSQL}; Server = localhost; Database = postgres; Port = 5432; Uid = postgres; Pwd = XXXXXX;"
I also tried the name of the odbc driver that I installed after installing postrgesql:
"Driver = {PostgreSQL ODBC Driver(UNICODE)}; Server = localhost; Database = postgres; Port = 5432; Uid = postgres; Pwd = XXXXXX;"
Setting up a DSN in odbc manager also works perfectly using the unicode driver, so I cant understand why i cant connect in my application, is there an error in the driver name that i am using in the connection string?
Your error message looks very strange. It tells about DSN not found. Are you sure you use connect string with Driver=...?
You can use ODBC connect string in several forms. At first you have created DSN, so you can use it:
DSN=mn_test; Uid=postgres; Pwd=postgres;
Then you can use other form of connect string:
Driver={PostgreSQL UNICODE};Server=127.0.0.1; Port=5493; Database=mn_test; Uid=postgres; Pwd=postgres;
Both work on my old 32 bit Windows environment. I test them with simple Python script (I use ActiveState Python in which there is simple odbc module):
import odbc
def test_odbc(connect_string):
print(connect_string)
db = odbc.odbc(connect_string)
c = db.cursor()
rs = c.execute("SELECT version()")
for txt in c.fetchall():
print('%s' % (txt[0]))
print('-----')
test_odbc('Driver={PostgreSQL UNICODE};Server=127.0.0.1; Port=5493; Database=mn_test; Uid=postgres; Pwd=postgres;')
test_odbc('DSN=mn_test; Uid=postgres; Pwd=postgres;')
When you created the DSN, did you create it with the correct odbcad tool? With the 64bit version found in C:\Windows\System32 if your application is 64bit and with the 32bit version found in C:\Windows\SysWOW64 if your application is 32bit?
I am trying to connect to an mdb file from C# 2013 using OdbcConnection. I used to have Office 2000 on my Windows 7 and Windows 8 machines, but I have upgraded to Office 2013 on both and it now longer works on either. My database is still in mdb format.
Here's the code:
const string myConnectionString = #"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Path\Mydb.mdb";
OdbcConnection connRL = new OdbcConnection();
connRL.Open();
Whatever I have tried I get the following error:
ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not
found and no default driver specified
I have Installed the "Microsoft Access Database Engine 2010 Redistributable" and the "2007 Office System Driver: Data Connectivity Components" but neither of them have made any difference. I can create a new Data Source from the VS 2013 Project menu and that all works at design time.
When I create a blank udl file and double click on it and go to the provider tab there's nothing listed about Access or Jet, but I can see the providers in the registry at HKEY_CURRENT_USER\Software\Microsoft\VWDExpress\12.0_Config\DataProviders. Why aren't they there?
What else can I do to get this to work? I have tried everything I can think of.
I assume you can't connect to the mdb through OdbcConnection. Anyway, to connect to the DB you must specify the connection string on your connection object which is not specified in your code.
To access mdb use code like this:
const string myConnectionString = #"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Path\Mydb.mdb";
using(var connRL = new OleDbConnection(myConnectionString))
{
//use your connection
}
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
We are trying to use 64 bit office (2013) from a 32 bit app.
Using the following connection string we are able to access .mdb files.
connection string: Driver={Microsoft Access Driver (*.mdb)};Dbq={Path_To_Db};Uid=;Pwd=;
But when we add *.accdb to the connection string we get the following error for both .mdb as well as .accdb database.
New Connection string: {Microsoft Access Driver (*.mdb, *.accdb)};Dbq={Path_To_Db};Uid=;Pwd=;
Error: [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified.
On a 32 bit office - the code is working fine.
Any suggestion?