Click here to Skip to main content
15,908,173 members
Home / Discussions / C#
   

C#

 
GeneralRe: Find unique strings for a string array Pin
N a v a n e e t h22-Dec-08 20:18
N a v a n e e t h22-Dec-08 20:18 
GeneralRe: Find unique strings for a string array Pin
George_George23-Dec-08 1:19
George_George23-Dec-08 1:19 
GeneralRe: Find unique strings for a string array Pin
Dragonfly_Lee22-Dec-08 21:14
Dragonfly_Lee22-Dec-08 21:14 
GeneralRe: Find unique strings for a string array Pin
George_George23-Dec-08 22:36
George_George23-Dec-08 22:36 
GeneralRe: Find unique strings for a string array Pin
Dragonfly_Lee24-Dec-08 15:25
Dragonfly_Lee24-Dec-08 15:25 
GeneralRe: Find unique strings for a string array Pin
George_George25-Dec-08 18:23
George_George25-Dec-08 18:23 
GeneralRe: Find unique strings for a string array Pin
Dragonfly_Lee25-Dec-08 19:44
Dragonfly_Lee25-Dec-08 19:44 
GeneralRe: Find unique strings for a string array Pin
George_George25-Dec-08 20:03
George_George25-Dec-08 20:03 
GeneralRe: Find unique strings for a string array Pin
Dragonfly_Lee25-Dec-08 20:22
Dragonfly_Lee25-Dec-08 20:22 
AnswerRe: Find unique strings for a string array Pin
DanB198323-Dec-08 0:28
DanB198323-Dec-08 0:28 
GeneralRe: Find unique strings for a string array Pin
George_George23-Dec-08 22:37
George_George23-Dec-08 22:37 
GeneralRe: Find unique strings for a string array Pin
DanB198324-Dec-08 0:22
DanB198324-Dec-08 0:22 
GeneralRe: Find unique strings for a string array Pin
George_George24-Dec-08 20:51
George_George24-Dec-08 20:51 
Questionhow can made c#.net messenger? Pin
mohammedali200622-Dec-08 10:48
mohammedali200622-Dec-08 10:48 
AnswerRe: how can made c#.net messenger? Pin
Christian Graus22-Dec-08 11:00
protectorChristian Graus22-Dec-08 11:00 
GeneralRe: how can made c#.net messenger? Pin
EliottA22-Dec-08 11:09
EliottA22-Dec-08 11:09 
GeneralRe: how can made c#.net messenger? Pin
Christian Graus22-Dec-08 11:18
protectorChristian Graus22-Dec-08 11:18 
GeneralRe: how can made c#.net messenger? Pin
EliottA22-Dec-08 11:20
EliottA22-Dec-08 11:20 
GeneralRe: how can made c#.net messenger? Pin
PIEBALDconsult22-Dec-08 13:10
mvePIEBALDconsult22-Dec-08 13:10 
GeneralRe: how can made c#.net messenger? Pin
Christian Graus22-Dec-08 13:45
protectorChristian Graus22-Dec-08 13:45 
GeneralRe: how can made c#.net messenger? Pin
PIEBALDconsult22-Dec-08 14:25
mvePIEBALDconsult22-Dec-08 14:25 
GeneralRe: how can made c#.net messenger? Pin
Christian Graus22-Dec-08 17:01
protectorChristian Graus22-Dec-08 17:01 
GeneralRe: how can made c#.net messenger? Pin
PIEBALDconsult23-Dec-08 12:22
mvePIEBALDconsult23-Dec-08 12:22 
QuestionEfficient way of accessing a Boolean from SQL Server Pin
Andreas_198322-Dec-08 9:35
Andreas_198322-Dec-08 9:35 
Hi,

I don't know if this was more suited to the database message board or not but I think my question is more to do with my code rather than the database.

I have a basic table with a few columns. One of them is a Bit type and is effectively a flag. All I want to do is get the flag value for a given ID.

I've tried using an output parameter in a stored procedure but I don't know the best way of retrieving the flag value and converting it to a Boolean in code. I don't think a SqlDataReader is ideal because it's only one value I want to return.

ALTER PROCEDURE SP_UserValid
	@ID    INT,
	@Valid BIT OUTPUT
AS
	SET NOCOUNT ON;
	SET @Valid = (SELECT [Valid] FROM tUsers WHERE ID = @ID)


Here's my code:

SqlConnection connection = new SqlConnection(_ConnectionString);
SqlCommand cmd           = new SqlCommand();
cmd.Connection           = connection;
cmd.CommandType          = CommandType.StoredProcedure;
cmd.CommandText          = "SP_UserValid";
cmd.Parameters.Add(new SqlParameter("@ID", userID));
cmd.Parameters.Add(new SqlParameter("@Valid", bValid));
cmd.Parameters["@Valid"].SqlDbType = SqlDbType.Bit;
cmd.Parameters["@Valid"].Direction = ParameterDirection.InputOutput;

connection.Open();
cmd.ExecuteNonQuery();

// How do I get the "Valid" as a Boolean value?

cmd.Connection.Close()


Thanks for looking Smile | :)
AnswerRe: Efficient way of accessing a Boolean from SQL Server Pin
Not Active22-Dec-08 10:02
mentorNot Active22-Dec-08 10:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.