Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
I have written code to tell if something has been processed. Now I just need to code something that sends a boolean from my code in C# to my table in SQL. It seems like it should be simple, but I am very new and can't figure it out, and Google hasn't turned anything out for me yet.

I thank anyone for their time reading this.

VB
if (notificationProcessed != null)
             if (notificationProcessed.passed)
//TODO: send Passed to Notification Table using Notification_Insert stored proc?
             _notificationList.RemoveAt(i);


and I'm trying to write that if the notification is "passed" then to put that in the "processed" table of my sproc:

SQL
SELECT TOP 1000 [NotificationID]
      ,[NotificationMasterID]
      ,[NotificationTypeID]
      ,[NotificationStatusID]
      ,[RecordID]
      ,[ModifyDate]
      ,[ModifyUser]
      ,[Processed]
  FROM [FOO].[dbo].[Notification]
Posted
Updated 14-Jul-14 5:49am
v2
Comments
[no name] 14-Jul-14 10:58am    
I believe that you will find that a bool is stored in SQL Server as a bit data type. Whatever database engine your are using might be different.
Hemant Singh Rautela 14-Jul-14 11:06am    
use BIT in SQL... :-)
And Send 1(True) or 0(False) from c# code
Member 10945412 14-Jul-14 11:37am    
I think the trouble I'm having is actually how to send it from C#, I have the column set as BIT, so it should be all good there. I'm just having issue with seeing that it's sent in my code in c#
Hemant Singh Rautela 14-Jul-14 11:41am    
Just show your code...

without your code no one can detect issue.. :-)
Member 10945412 14-Jul-14 11:49am    
Sorry, added code!

As the others have suggested, in SQL Server you can use a datatype of BIT[^]
See also SQL Data Type Mappings[^]

Note that the database handlers built into .net should take care of any conversion for you. For example you can do something like this...
SqlCommand cmd = new SqlCommand("insert into Product (ProductName, Active) values(@prod, @active)", con);
cmd.Parameters.AddWithValue("@prod", "A new product");
cmd.Parameters.AddWithValue("@active", true);
int rowsAffected = cmd.ExecuteNonQuery(); 
 
Share this answer
 
v2
You have to take datafield bit type in table and then you can store boolean or bool value to database.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900