I am new to SqlServer, have been using Oracle in a prior life.
I have written a very simple stored procedure in SQL Server and it (the
query) looks like the following...
Select AD_ID, First_Name, Last_Name, User_Type, Phone_Nbr, Email_Addr
From dbo.User_Tbl
Where UPPER(AD_ID) = UPPER(@AD_ID)
and UPPER(User_Type) = UPPER(@User_Type)
I have placed (not shown) the @@ROWCOUNT into the procedure and when I debug
it in Visual Studio 2005, it shows a rowcount of 1, and this is how many rows
I was expecting. A Datareader is returned, but when I perform the While
(dr.Read()) it immedialtely falls out and does not read any records.
Any idea as to what I might be doing wrong such that no records are returned?
Thanks in advance for your assistance!! 6 1463
I have placed (not shown) the @@ROWCOUNT into the procedure and when I debug
it in Visual Studio 2005, it shows a rowcount of 1, and this is how many rows
I was expecting. A Datareader is returned, but when I perform the While
(dr.Read()) it immedialtely falls out and does not read any records.
If executing the query in query analyser works fine then it's probably
something in your .NET code. Could you post the snippet which is failing?
Well I use a lot of general routines to prepare the sql statements and create
the data reader that it becomes a bit complex to show snipits...but here
goes...
Here is the code to create my parameters....
parms[0] = TblUtilites.GetParameter(TblUtilites.DataBaseType. SqlServer,
"@AD_ID", ParameterDirection.Input, parmValues[0],
TblUtilites.DataType.SqlDbTypeChar, 8);
parms[1] = TblUtilites.GetParameter(TblUtilites.DataBaseType. SqlServer,
"@User_Type", ParameterDirection.Input, parmValues[1],
TblUtilites.DataType.SqlDbTypeVarChar, 50);
parms[2] = TblUtilites.GetParameter(TblUtilites.DataBaseType. SqlServer,
"@Active_Inactive_All", ParameterDirection.Input, parmValues[2],
TblUtilites.DataType.SqlDbTypeChar, 1);
Here is the code to create my Command.. (conMgr is a class I have created
which hold my connection, my command, the Data reader...)
try
{conMgr.Sql_Cmd = new SqlCommand(qryNameOrQryString, conMgr.Sql_Con ); }
catch (Exception e)
{ conMgr.Error_Message = e.Message; }
Here is the code to create the data reader (Again, conMgr holds the command
and data reader)
conMgr.Data_Reader = (IDataReader)conMgr.Sql_Cmd.ExecuteReader();
Here is the code to read the data reader... (My count is always zero)
IDataReader dr = cm.Data_Reader;
int cnt = 0;
if (dr != null)
{
while (dr.Read())
{ cnt++; }
dr.Close();
}
if (cnt 0)
{ return true; }
else
{ return false; } // always returns false
Well I use a lot of general routines to prepare the sql statements and
create
the data reader that it becomes a bit complex to show snipits...but here
goes...
I can't really tell what's going on because of your helper class. I suspect
the parameters arn't being sent across correctly. Have you tried running SQL
Profiler while executing the code to see what is actually being sent to SQL
Server?
Have never run the profiler...Is there such a thing with Sql Express with the
Server Management Studio installed?
Have never run the profiler...Is there such a thing with Sql Express with
the
Server Management Studio installed?
Hmm, I don't think it comes with SQL Express. Do you have SQL Server
Management Studio Express installed or the full SQL Server Management Studio?
I do not have the full SQL server Management studio installed although I have
a MSDN subscription which I believe provides me that. I read that it does not
come with the version which is freely downloaded from the web.
I changed my stored procedure to write the values passed into the stored
procedure to a temporary database and I discoved what the problem was. I had
changed the code from passing an in-stream SQL statement to a stored
procedure and forgot that I no longer needed to enclose my string variables
in quotes. Silly mistake, but I just could not see it...so obvious that it
could knock you over but...
Thanks for your assistance!! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Natan Vivo |
last post by:
I had to built a custom data paging control for my asp.net app and SQL
Server.
This is what I'm doing:
1. do a SELECT to a SqlDataReader
2. create a DataTable with data from GetSchema()
3....
|
by: Joe |
last post by:
Anyone can suggest the best method of reading XML and adding data to
ListView?
Here is the xml data structure::
<xml>
<site>
<url>http://www.yahoo.com</url>
<lastupdate></lastupdate>...
|
by: mosipenko |
last post by:
I used to have a problem with DBNull, but now my issue is:
System.InvalidOperationException: Invalid attempt to read when no data
is present
Here's my code behind:
Private Sub...
|
by: Hrvoje Voda |
last post by:
I'm using this store procedure to return data from sql server.
SqlDataReader sqlRead = null;
System.Data.SqlClient.SqlCommand ProfileBLOBSelect = new
System.Data.SqlClient.SqlCommand();
...
|
by: Jim Heavey |
last post by:
I have a SQL stored procedures which evaluate the values passed in parameters
and then based on those values reads the appropriate records.
I run the stored procedure in VS 2005 Debug mode and it...
|
by: shapper |
last post by:
Hello,
I have an SQL database table with 20 fields: Field_01, Field_02, etc.
I am creating a string with StringBuilder.
I want to include in my string the fields of one record of the
database....
|
by: cjl |
last post by:
P:
Stupid question:
reader = csv.reader(open('somefile.csv'))
for row in reader:
do something
Any way to determine the "length" of the reader (the number of rows)
before iterating through...
|
by: Amitava Maity |
last post by:
Hello,
I have a data file (data.csv) that is something like this:
data, Conductor, ACSR
data, diameter, 0.02862
data, cross-section, 0.0004845
data, weight, 1.621
data, Mod, 7000000000...
|
by: =?Utf-8?B?SkI=?= |
last post by:
Hello
My pgm1 (User Interface Level) passes an empty ArrayList to pgm2
(Business Logic Level). pgm2 then calls pgm3 (Data Access Level) to populate
the ArrayList.
Question1: When pgm2 gets...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |