TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Neil Kirk
NA
1
0
the Size property has an invalid size of 0
Mar 2 2009 11:45 AM
Hey there all
I am trying to retrieve data from a SQL 2008 database and receiving the above error from the following code:
SqlParameter pID = new SqlParameter("@pID", SqlDbType.Int);
SqlParameter pName = new SqlParameter("@pName", SqlDbType.VarChar);
SqlCommand cmdGetInfo = new SqlCommand("sp_GetDirectoryInfo",dbConnection);
cmdGetInfo.CommandType = CommandType.StoredProcedure;
cmdGetInfo.Parameters.Add(pID);
cmdGetInfo.Parameters.Add(pName);
pName.Direction = ParameterDirection.Output;
pID.Value = intID;
dirToReturn.ID = intID;
try
{
cmdGetInfo.ExecuteNonQuery();
dirToReturn.Name = (string)cmdGetInfo.Parameters["@pName"].Value;
return dirToReturn;
}
catch (Exception err)
{
Console.WriteLine(err.ToStrin());
}
The stored procedure is:
USE [TestDB]
GO
/****** Object: StoredProcedure [dbo].[sp_GetDirectoryInfo] Script Date: 03/02/2009 13:58:23 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[sp_GetDirectoryInfo]
(
@pID int,@pName varchar OUTPUT
)
AS
SET NOCOUNT ON
SELECT @pName = Directory
FROM tblDirectoryInfo
WHERE DirectoryID = @pID
RETURN
Does anyone know why this won't work? I have done the same thing and returned integers with no problem...
I am fairly new to C#, so please bear with any stupid questions...
Thanks in advance!
Reply
Answers (
1
)
Progress bar with Background worker till xml file gets uploaded.
easy way to format numbers to strings?