[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 205
  • Last Modified:

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
0
rbgerman
Asked:
rbgerman
  • 2
1 Solution
 
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
 
Type25Commented:
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
 
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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now