saving a textbox into SQL Server

hey all---

I am a newbie here.  I am trying to write a SQL statement in ASP.NET to do an insert into a table on MS SQL Server.  My dilemma is that all of the fields in the table are ints and on the web form, they are all check boxes.  How can I set this up.  The username comes from a session.

strSQL = "INSERT INTO tblPurpose(username, check1, check2, check3, "
strSQL += "check4, check5, check6) VALUES('"
strSQL +=

where do i go from here?

rbg
LVL 1
rbgermanAsked:
Who is Participating?
 
Type25Connect With a Mentor Commented:
don't wrap the values around semi quotes though... ie

INSERT INTO tblPurpose(username, check1)  VALUES ("Rob", 1)

sooo....

strSQL = "INSERT INTO tblPurpose(username, check1, check2, check3, "
strSQL += "check4, check5, check6) VALUES("
strSQL += Convert.ToInt32(yourCheckBox.Checked) + "," + Convert.ToInt32(checkBoxNo2.Checked).... etc


is what you want...  

Cheers,
T25!
0
 
Type25Commented:
strSQL = "INSERT INTO tblPurpose(username, check1, check2, check3, "
strSQL += "check4, check5, check6) VALUES('"
strSQL += Convert.ToInt32(yourCheckBox.Checked) + "," + Convert.ToInt32(checkBoxNo2.Checked).... etc
0
 
rbgermanAuthor Commented:
i am actually getting a server error.  my table has a PK of a uniquieidentifier, a varchar called username, and 6 checkboxes that are ints.  On the last line of the strSQL it gives the error of input string is not in correct format....what's up with that?

rbg

0
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.

All Courses

From novice to tech pro — start learning today.