Oracle DataAccess error at the Fill method
Hello,
I am getting an Oracle.DataAccess.Client.DataException, Object Reference not set to an instance of an object, when the .Fill method is called, on some PCs but not other. The error occurs on the .Fill method below. It seems to think the dataset is null, but on other machines it runs fine. What bothers me the most is that this code ran fine a couple of days ago. I have tried re-writing the code on this machine and I still have the same problem with the same errors. If I use VS2005 designer to define a dataset and dataadapter to an Oracle table, that works fine. Any idea what might be wrong with the code? I haven't been able to get any code to work.
We are running Oracle 9.2 and ODT with ODAC10202
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Oracle.DataAccess.Client;
namespace Test2
{
public partial class Form1 : Form
{
private OracleConnection oraConn = new OracleConnection();
private OracleDataAdapter da = new OracleDataAdapter();
private OracleCommand cmd = new OracleCommand();
private DataSet ds = new DataSet();
public Form1()
{
InitializeComponent();
oraConn.ConnectionString = "Data Source=ORADB;User Id=XXXX;Password=oracle;";
cmd.CommandText = "select project_id from project";
cmd.Connection = oraConn;
da.SelectCommand = cmd;
da.Fill(ds); // the error occurs here, see below for error
}
}
}
The error exception is below:
Oracle.DataAccess.Client.OracleException was unhandled
Message=""
ErrorCode=-2147467259
StackTrace:
at Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure)
at Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, Object src)
at Oracle.DataAccess.Client.OracleConnection.Open()
at Oracle.DataAccess.Client.OracleCommand.ExecuteReader(Boolean requery, Boolean fillRequest, CommandBehavior behavior)
at Oracle.DataAccess.Client.OracleDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
at Test2.Form1..ctor() in C:\Documents and Settings\xx\My Documents\Visual Studio 2005\Projects\Test2\Test2\Form1.cs:line 28
at Test2.Program.Main() in C:\Documents and Settings\xx\My Documents\Visual Studio 2005\Projects\Test2\Test2\Program.cs:line 17
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()