473,395 Members | 1,653 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,395 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 1099

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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.