473,387 Members | 1,789 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Count Error from Oracle database

Hi there

I've written the following method which counts the number of times a specific attribute value appears in the database. It works fine in Oracle SQL Developer but returns a: 'ORA-01722:invalid number' error when running in ASP.NET, so it must be an ASP.NET / C# problem.

The NTID attribute is a VarChar2, but only 3 values are actually non-numeric. Would it make any difference if I changed the data type to NUMBER? Currently, I can't change the data type as there are already values in the table.

Expand|Select|Wrap|Line Numbers
  1. public int CheckRegistration(string userId)
  2.         {
  3.             using (OracleConnection oce = new OracleConnection(ConnectionString))
  4.             {
  5.                 string user = string.Format("'{0}'", userId);
  6.                 oce.Open();
  7.                 OracleCommand command = oce.CreateCommand();
  8.                 command.CommandType = CommandType.Text;
  9.  
  10.                 string querystring = string.Format(@"
  11.                 SELECT COUNT(*) FROM TBLADMINCODES
  12.                 WHERE NTID = {0}", user);
  13.                 command.Prepare();
  14.             }
  15.             return (int) command.ExecuteScalar();
  16.         }
I can't change the data type anyway as there is already data in the table.
What can I do to eliminate this error?

Thanks Matt.
Jun 8 '09 #1
0 1350

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Colin Steadman | last post by:
What is the best way to control is a transaction? I've done a little test and both of the examples below seem to do the job, but I was wondering which is the better method, this: If err.number <>...
6
by: Hari Om | last post by:
Here are the details of my error log files: I execute the command and get following message at console: ---------------------------------------------------------------------- ../sqlldr...
0
by: Cherrish Vaidiyan | last post by:
sir, The following are the steps that i followed in setting up standby database on Red hat Linux 9. i am using Oracle 9i. i have followed the steps in this site : ...
7
by: Cherrish Vaidiyan | last post by:
hello, I am been getting mad with so many doubts and errors.. I have posted some doubts,test cases regarding listener,replication and standby database.But i havent got any response..(I am...
4
by: Kong Li | last post by:
Environments: 1. WinXP SP1, MDAC 2.7 SP1 (Microsoft ODBC for Oracle is 2.573.9030.0), Oracle client 9.2.0.1. 2. Win2000 SP4, MDAC 2.7 SP1 (Microsoft ODBC for Oracle is 2.573.9030.0), Oracle...
3
by: Nathan Sokalski | last post by:
When I attempt to run a form created with Oracle9i Forms Builder I receive a dialog box asking for the following info: User Name: Password: Database: I obviously know my User Name and...
0
by: aaronandbree | last post by:
I have been searching the boards trying to find an answer to this question and no luck. I am using a query similar to this: Select count(col1) from table1 I was having a hard time accessing...
3
by: hakiran | last post by:
Hello all, I have been using Perl DBI the last 6months or so. I use it extensively with MySQL. But recently i tried to access Oracle DB with it and was having trouble. Any help would be...
2
by: khalidanwar123 | last post by:
i am getting the following error while updating a clob field. ERROR java.sql.SQLException: Data size bigger than max size forthis type: 4003 19:28:27,499 ERROR at...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.