473,387 Members | 1,592 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.

scalar and untrapable error

I have a problem
When I execute scalar to retreive some data,if it is not
found I get an error which I cannot trap
When nothing is found, response is "" (length=0), but it comes from catch.
Also, if I don't include conn.close in catch,conenction remains open

Point is that I have read on several places that using scalar is the fastest
method to get single data and I use it often (in one report more than 1000
times).
When I use DataReader,it is much slower. So if anybody can help me how to
trap when nothing is found
public string getEntry(string cs, string sql)
{
OleDbConnection conn = new OleDbConnection(cs);
string response="";
try
{

conn.Open();
OleDbCommand idCMD = new OleDbCommand(sql, conn);

response = (string)idCMD.ExecuteScalar();

if (response.Length<1)
return "failed";

return response;
}

catch
{
if (conn !=null) {conn.Close();}
return "failed";
}
finally
{
if (conn !=null) {conn.Close();}
}
}


Jul 19 '05 #1
0 1098

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Simon Riggs | last post by:
I'm trying to create some User Defined Functions, which act as scalar functions. I can successfully create a UDF like this: drop function arraylistset; CREATE FUNCTION ArrayListSet (ArrayList...
0
by: frankie | last post by:
I have a problem When I execute scalar to retreive some data,if it is not found I get an error which I cannot trap When nothing is found, response is "" (length=0), but it comes from catch. Also,...
4
by: al havrilla | last post by:
hi all what does the phrase: "scalar deleting destructor" mean? i'm getting this in a debug error message using c++ 7.1 thanks Al
0
by: frankie | last post by:
I have a problem When I execute scalar to retreive some data,if it is not found I get an error which I cannot trap When nothing is found, response is "" (length=0), but it comes from catch. Also,...
5
by: Eli | last post by:
Hi, I want to check whether a value is a scalar. A scalar can be: - None (null) - string - number (integer, float) - boolean How can I validate a value is one of these types? I care about...
2
by: venu reddy | last post by:
Hi all, I wrote an example code like this. I am getting error as " conversion to non-scalar type requested error". help me!!. #include<string.h> typedef struct { int val; char data;
0
by: roamnet | last post by:
hi i created database file with .mdf extention ,sql server as a source and use grid view to display data there're no problem in data retrieve and display,but i want to edit it or insert new...
2
by: nshishir | last post by:
In oracle, there is a performance improvement if scalar subqueries are used instead of joins. Does this hold good for Db2 (8.2) too?
1
by: Tony M | last post by:
vs 2005 - vb .net - web forms - xp pro Can't figure out why I keep getting the error Must declare the scalar variable "@CheckUser". The error happens on SqlDA.Fill(SqlDS). Just trying to make...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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.