473,386 Members | 1,785 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,386 software developers and data experts.

Stored Procedure to provide results gives exception in c# code

dbrewerton
115 100+
Ok, I'm not exactly certain what the problem is here but I will say I'm frustrated. The Stored Proc if directly executed works fine. When I try using it as part of loading a data table, it give an exception. However, the exception isn't really giving me any specific conditions, it says there's a problem but no details. My code:

Expand|Select|Wrap|Line Numbers
  1.                 try
  2.                 {
  3.                     using (SqlCommand command = new SqlCommand("sp_TestProc", sqlconn))
  4.                     {
  5.                         command.CommandType = CommandType.StoredProcedure;
  6.                         sqlconn.Open(); // opening the connection
  7.  
  8.                         SqlDataReader dr = command.ExecuteReader(); // this is where it goes south
  9.  
  10.  
  11.                         DataTable dtt = new DataTable();
  12.                         dtt.Load(dr);
  13.                     }
  14.                 }
  15.                 catch (Exception ex)
  16.                 {
  17.                     Console.WriteLine("Error: " + ex.ToString());
  18.                 }
  19.                 finally
  20.                 {
  21.                     sqlconn.Close();
  22.                 }
  23.  
Mar 5 '20 #1
0 2067

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

Similar topics

0
by: Ted | last post by:
Can anyone give me an example of calling a stored procedure with parameters and getting back the results? I can't find anything in the docs that talks about calling stored procedures. Ted
1
by: Bob James | last post by:
Hi, How can I store a stored procedure's results(returning dataset) into a table? Bob *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get...
4
by: Robin Tucker | last post by:
Hi, I'm trying to determine with my program whether or not a given database supports a given feature set. To do this I'm querying for certain stored procedures in the sysobjects table and if...
5
by: MS | last post by:
Here's my simple stored procedure: ALTER PROCEDURE GetMemberIDByEmail @Email EmailAddress, @ID int OUTPUT AS SELECT @ID = ID FROM tbl_Member WHERE Email=@Email RETURN
1
by: RSH | last post by:
Im trying to create a stored procedure of the following code. I want to set it so that I have to send the first 4 variables (@DB, @BackUpFile,@TestDB,@RestoreFile). I am having trouble when i try...
3
by: nikhilbhavsar | last post by:
Hi Frnds , I want to debug a stored procedure. It is written in SQL. I am using Developement center for creating stored procedures. I built the stored procedure with Debug option and also...
7
by: Siv | last post by:
Hi, I have a stored procedure that I want to execute and then wait in a loop showing a timer whilst it completes and then carry on once I get notification that it has completed. The main reason...
2
by: thecodewhore | last post by:
OK, so I have a stored procedure that ends like this .... select @PulpMill as pulp_mill, @Supplier + ' - weighted' as supplier, @Species as species select interval_date, weight_multiplied_cqi /...
23
by: Fred | last post by:
if I use mysql_real_escape_string on all INSERT or UPDATE queries, then would a stored procedure provide any extra protection? the user has to be granted UPDATE and/or INSERT privileges anyway. ...
0
by: jp140768 | last post by:
Hi, I am developing a Cobol/400 system, which will use information contained within a DB2/400 system, its possible that some of this information will also be used within a PC front end system. ...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.