Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
|
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 12th, 2003, 09:57 PM
Authorized User
 
Join Date: Jun 2003
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default in-line parameters in stored procedures

Hello,

I'm trying to execute a SqlCommand using an SQL string that includes the name of the stored proc and two input parameters -- but I'm not getting any records returned, even though when I run the stored proc in query analyzer or from server explorer in vs.net, I do get a record. Here's my code:

public SqlDataReader RunSP(string proc, ref string errMsg)
{
    try
    {
        SqlConnection cnn = new SqlConnection(_connectString);
        cnn.Open();
        SqlCommand cmd = new SqlCommand(proc, cnn);
        return cmd.ExecuteReader();
    }
    catch (Exception e)
    {
        errMsg = e.Message;
        return null;
    }
}

Here's the value of the proc string:
Document_Load 48, 'X233X2983JIOKSJB'

I know this should be returning records, but it's not. Does anything jump out as being wrong? Oh, and here's the connect string I'm using, in case I have a wrong parameter or something:

Data Source=mycomputername;Initial Catalog=DatabaseName;User Id=steve;Password=password;

Thanks in advance if anyone can shed some light. In case you're wondering, I'm not building parameters because I want this to be a generic method that I can call from different objects, just passing in the SQL string.

Steve
__________________
Steve
iTek Corporation
http://itekcorp.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Stored Procedures KeviJay VB Databases Basics 1 June 5th, 2008 07:17 AM
stored procedures thillaiarasu ASP.NET 2.0 Basics 2 May 3rd, 2007 07:55 AM
SQL Pass though parameters to stored procedures blinton25 SQL Server 2000 3 March 29th, 2004 02:49 PM
Calling Stored procedures with out parameters bansalh Access 1 November 25th, 2003 04:30 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.