Update Access with C# .NET, using OleDbCommand Parameters to Pass Checkbox Value

I figure this is simple but I can't find the answer...I am updating an access database using ASP.NET C#.  The form has several check box controls that I want to update in the DB.  I am not sure how to create the OleDbCommand parameters for checkbox.  I think access checkbox values are -1, 0, and NULL but I can't figure out how to specify the datatype (if it is even necessary) and the parameter in the UPDATE Statement.

void updateRecord(Object Source, EventArgs E){
      //set connetction objects
      OleDbConnection objConn = new OleDbConnection(strConnection);
      OleDbCommand objCmd;
      OleDbDataReader objRdr;
      objCmd = new OleDbCommand("UPDATE omniforms SET name=@name, new=@newStatus, dayNight=@dayNight, billingStatus=@billingStatus, signatureStatus=@signatureStatus WHERE " + Request.QueryString["id"] + "", objConn);
      objCmd.Parameters.Add("@name", txtName.Text);
      objCmd.Parameters.Add("@newStatus", ddlNewStatus.SelectedItem.Value);
       objCmd.Parameters.DbType("@dayNight", ??????);  //checkbox named chkDayNight
      objCmd.Parameters.Add("@billingStatus", ddlBillingStatus.SelectedItem.Value);
      objCmd.Parameters.Add("@signatureStatus", ddlSignatureStatus.SelectedItem.Value);                  
      objConn.Open();
      objCmd.ExecuteNonQuery();
      objConn.Close();
}
drliebsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AerosSagaCommented:
Access should be looking for True/false or Yes/No depending on how you set it up.

0
AerosSagaCommented:
you may be able to pass the index, but it is not neccesary.
0
AerosSagaCommented:
I usually handle it with something like this
 If Me.cbNewsletter.Checked Then
                    Session("Newsletter") = "True"
                End If

where cbNewsletter is my checkbox
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

AerosSagaCommented:
and no you don't have to specify a datatype
0
drliebsAuthor Commented:
Can you fill in the blank or write out the correct code?

objCmd.Parameters.DbType("@dayNight", ??????);  //checkbox named chkDayNight
0
AerosSagaCommented:
If Me.chkDayNight.Checked Then
                    Session("DayNight") = "True" ' or yes if you defined it that way
                Else
Session("DayNight") = "False" ' or no if you defined it that way
                End If

objCmd.Parameters.DbType("@dayNight", Session("DayNight"));  //checkbox named chkDayNight

Aeros
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AerosSagaCommented:
Why did I get a 'C'?  Did you have any further questions?  Since you did not post them I am assuming no, and ask that you change my grade.

Aeros
0
drliebsAuthor Commented:
Thanks, I ended up doing something a little different but you got me in the right direction, this is the C# code I ended up using

      if (chkDayNight.Checked){
      objCmd.Parameters.Add("@dayNight", true);
      }
      else{
      objCmd.Parameters.Add("@dayNight", false);      
      }
0
drliebsAuthor Commented:
I asked for C# code, I don't see any reason to use a variable and the code you posted was giving me errors.
0
AerosSagaCommented:
I would have clarified or attempted to help if you had asked.
0
drliebsAuthor Commented:
I don't mean to sound rude and I don't mean for a "C" grade to belittle you or effect your score, but the choice was "average" and I thought it was an average answer, an exceptional answer would have been more complete.  Thank you again, I hope that others will find the thread usefull.
0
AerosSagaCommented:
Ask 10 Experts this question, and you'll get 10 different answers. One thing is certain: Grading at Experts Exchange is NOT like school. Here's what EE says:

    Although we use an A-D scale here at Experts Exchange, it works differently than, say, school grades. If one or more Experts' proposals are accepted as answers, they should usually be given an A or B grade, since they have taken the time to provide you with a working solution. If a possible solution is incomplete - ask for clarification or details before accepting the answer and grading it. People should not be given lower grades because of incorrect grammar or because you just accepted their answer or comment to close the question. Keep in mind, your question and any follow-up comments should be focused so that there can be a specific answer. The following is a good guideline to follow when grading:

        * A: The Expert(s) either provided you with a thorough answer or they provided you with a link to information that thoroughly answered your question. An "A" can also be given to any answer that you found informative or enlightening beyond the direct question that you asked.
        * B: The Expert(s) provided an acceptable solution, or a link to an acceptable solution, that you were able to use, although you may have needed a bit more information to complete the task.
        * C: Because Experts' reliability are often judged by their grading records, many Experts would like the opportunity to clarify if you have questions about their solutions. If you have given the Expert(s) ample time to respond to your clarification posts and you have responded to each of their posts providing requested information; or if the answers, after clarification, lack finality or do not completely address the issue presented, then a "C" grade is an option. You also have the option here of just asking Community Support to delete the question.

    Remember, the Expert helping you today is probably going to be helping you next time you post a question. Give them a fair chance to earn an 'Excellent!' grade and they'll provide you with some amazing support. It's also true that a "C" is the lowest grade you can give, and the Experts know that -- so use it judiciously.

Only the Moderators and Page Editors have the choice to give a D grade. Beyond that, in a practical sense, the grading guidelines have "softened" a bit over the last year or two; one might expect that the majority of grades would be Bs (a standard "bell" curve), but the fact is that the culture of the site has caused there to be an inordinately high percentage of As. The Moderators have been instructed to ensure that the As they award are actually "Excellent" answers. Similarly, the C grade is the lowest that can be given by a member, a fact which should be kept in mind when grading as well.

The use of a C in a vindictive manner is likely to be changed by a Moderator. You may not like the answer you get, and in some cases, and you may not like the way it is delivered, but if it is deemed to be accurate, no less than a B is an acceptable grade.
0
drliebsAuthor Commented:
Your post was fast, I can't always count on that and I was able to figure it out easy enough.  Does a "C" make you look bad on this forum? I will change it to a B if that is what you are concerned about.  I appreciated the help, I really do.
0
drliebsAuthor Commented:
With that in mind I appologize and a B would be more appropriate...now how do I correct this?
0
AerosSagaCommented:
Yes it does, and I was more than willing to help.  I understand that you feel it was not the best answer, but since you did not ask for further help or clarification I request you post a message here and asked for the grade to be changed to a B.

http://www.experts-exchange.com/Community_Support/askQuestion.jsp
0
AerosSagaCommented:
Thank you so much my friend.

Aeros
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.