Question on UniDirect .Net2 Mobile
Posted: 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();
}
}
}
}
}
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();
}
}
}
}
}