Question on UniDirect .Net2 Mobile

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for universal data access
Post Reply
kk
Posts: 5
Joined: Tue 20 Nov 2007 10:37

Question on UniDirect .Net2 Mobile

Post by kk » Tue 20 Nov 2007 10:44

I have installed the oracle 10gR2 as the server.
In the palm, I have followed the code from the example of UniDirect, however, I got the error of "InvalidProgramException" when I build the connection string.

Below is the code that I have tested:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;

namespace DeviceApplication2
{
public partial class Form1 : Form
{
private CoreLab.UniDirect.UniCommand uniCommand;
private CoreLab.UniDirect.UniConnection connection;
private Hashtable connectionParameters = new Hashtable();

private bool testConn;

public Form1()
{
InitializeComponent();
}

private void BuildConnStr()
{
connectionParameters.Clear();

try
{
connectionParameters["Provider"] = "Oracle";
connectionParameters["Server"] = "192.168.10.160";
connectionParameters["Sid"] = "orcl";
connectionParameters["User Id"] = "scott";
connectionParameters["Password"] = "tiger";

StringBuilder connectionString = new StringBuilder();
foreach (DictionaryEntry param in connectionParameters)
{
connectionString.Append((string)param.Key + "=" + (string)param.Value + ";");
}

connection = new CoreLab.UniDirect.UniConnection(connectionString.ToString().ToLower());
}
catch (Exception e)
{
MessageBox.Show("Connection: " + e.Message);
testConn = false;
}
}

private void button1_Click(object sender, EventArgs e)
{
testConn = true;

BuildConnStr();

if (testConn != false)
{
try
{
uniCommand = new CoreLab.UniDirect.UniCommand();
uniCommand.Connection = connection;

uniCommand.CommandText = "select dname from dept where deptno = 10";

CoreLab.UniDirect.UniDataReader dr = uniCommand.ExecuteReader();
if (dr.Read()) // C#
{
label1.Text = dr.GetString(0);
}
}
catch (Exception ex) // catches any error
{
MessageBox.Show(ex.Message.ToString());
}
finally
{
connection.Close();
}
}
}
}
}

AlexeyB

Post by AlexeyB » Thu 22 Nov 2007 10:54

First of all make sure that the following conditions are true:
1. You have CoreLab.UniDirect.Oracle.dll on your palm in the app's directory.
2. You have CoreLab.Oracle.dll on your palm in the app's directory.
3. You have the application config file (DeviceApplication2.exe.config) with BindingRedirect element for your CoreLab.Oracle assembly. This is needed when version of CoreLab.Oracle.dll differs from version that UniDirect (CoreLab.UniDirect.Oracle particularly) uses.

For the third case, here is an example of application config file DeviceApplication2.exe.config:












where newVersion is the version of your CoreLab.Oracle.dll, oldVersion is the version that UniDirect 2.05.7.1 uses.

Note about the code you posted: you have to open a connection before you execute reader.

kk
Posts: 5
Joined: Tue 20 Nov 2007 10:37

Post by kk » Thu 29 Nov 2007 04:06

The code of "connection.Open();" is missing after "connection = new CoreLab.UniDirect.UniConnection(connectionString.ToString().ToLower()); ". It is becuse I want to identify the error is caused by which statement.

It is sure that the error statement is:
"connection = new CoreLab.UniDirect.UniConnection(connectionString.ToString().ToLower()); "

Becuase the error statement is "Connection: InvalidProgramException", what can i do?

By the way, I found that the Palm do not have CoreLab.Oracle.dll in the app's directory. It is not existed in neither my palm nor PC that have installed Uni.Direct .NET 2

cma019
Posts: 1
Joined: Wed 05 Dec 2007 01:18

Post by cma019 » Wed 05 Dec 2007 01:20

Hi there

Isn't CoreLab.Oracle.dll only available in OraDirect mobile?
Cos i couldn't find this dll in the unidirect mobile.

Thanks

AlexeyB

Post by AlexeyB » Wed 05 Dec 2007 17:04

Yes, CoreLab.Oracle.dll is available only in OraDirect .NET mobile.

UniDirect mobile works only with pre-installed OraDirect .NET, MyDirect .NET, PostgreSQLDirect .NET and standard SqlClient providers. The Mobile edition does not include any bundled providers and won't work without them if you want to connect to Oracle, MySQL or PostgreSQL servers. You can see that in http://crlab.com/unidirect/ feature table. These assemblies are not deployed automatically, you should copy them manually.

Post Reply