help with datasets, datatables, etc

  • Thread starter Thread starter Dave Cullen
  • Start date Start date
D

Dave Cullen

I have a C# database app (someone else's code) that started crashing
when I changed some values in a data table. If I use numeric data in
this field, it works OK. Changing to non-numeric strings causes Oracle's
ORA-01722 error (invalid number). I know what is wrong, but I don't know
how to fix the application to allow non-numeric data. The table data is
VARCHAR2.

This is a snippet from the code that crashes:
CCNUMBER is the column that I added some non-numeric data into.

string cmd = "SELECT NONINCREMENTING FROM PXCCDB WHERE CCNUMBER = " +
cboProxCC.SelectedItem.ToString().Trim() + " ORDER BY CCNUMBER";

OleDbDataAdapter da = new OleDbDataAdapter(cmd, cnCPS); // cnCPS is the
connection

DataSet ds = new DataSet();

try
{
da.Fill(ds, "ProxCC"); // throws exception here
}

What is "ProxCC"? I can't find any references to that name in the
application. And how does the text data from the database get assigned
to a number? That's the part I can't figure out.
 
Hi,
inline

Dave Cullen said:
I have a C# database app (someone else's code) that started crashing
when I changed some values in a data table. If I use numeric data in
this field, it works OK. Changing to non-numeric strings causes Oracle's
ORA-01722 error (invalid number). I know what is wrong, but I don't know
how to fix the application to allow non-numeric data. The table data is
VARCHAR2.

This is a snippet from the code that crashes:
CCNUMBER is the column that I added some non-numeric data into.

string cmd = "SELECT NONINCREMENTING FROM PXCCDB WHERE CCNUMBER = " +
cboProxCC.SelectedItem.ToString().Trim() + " ORDER BY CCNUMBER";

Try :
string cmd = "SELECT NONINCREMENTING FROM PXCCDB WHERE + CNUMBER = '" +
cboProxCC.SelectedItem.ToString().Trim() + "' ORDER BY CCNUMBER";

There should be a single quote before and after the string value.
OleDbDataAdapter da = new OleDbDataAdapter(cmd, cnCPS); // cnCPS is the
connection

DataSet ds = new DataSet();

try
{
da.Fill(ds, "ProxCC"); // throws exception here
}

What is "ProxCC"? I can't find any references to that name in the

The result of the query is stored in a table called ProxCC (instead of
PXCCDB) inside the dataset, you can later refer to it as da["ProxCC"] or
da[0] .
application. And how does the text data from the database get assigned
to a number? That's the part I can't figure out.

hth,
greetings
 
You have a sharp eye :-) Thanks very much.

drc

Hi,
inline

Dave Cullen said:
I have a C# database app (someone else's code) that started crashing
when I changed some values in a data table. If I use numeric data in
this field, it works OK. Changing to non-numeric strings causes Oracle's
ORA-01722 error (invalid number). I know what is wrong, but I don't know
how to fix the application to allow non-numeric data. The table data is
VARCHAR2.

This is a snippet from the code that crashes:
CCNUMBER is the column that I added some non-numeric data into.

string cmd = "SELECT NONINCREMENTING FROM PXCCDB WHERE CCNUMBER = " +
cboProxCC.SelectedItem.ToString().Trim() + " ORDER BY CCNUMBER";

Try :
string cmd = "SELECT NONINCREMENTING FROM PXCCDB WHERE + CNUMBER = '" +
cboProxCC.SelectedItem.ToString().Trim() + "' ORDER BY CCNUMBER";

There should be a single quote before and after the string value.
OleDbDataAdapter da = new OleDbDataAdapter(cmd, cnCPS); // cnCPS is the
connection

DataSet ds = new DataSet();

try
{
da.Fill(ds, "ProxCC"); // throws exception here
}

What is "ProxCC"? I can't find any references to that name in the

The result of the query is stored in a table called ProxCC (instead of
PXCCDB) inside the dataset, you can later refer to it as da["ProxCC"] or
da[0] .
application. And how does the text data from the database get assigned
to a number? That's the part I can't figure out.

hth,
greetings
 
Back
Top