-1

hello I'm looking to just do a simple reason for what this is not working ... i have tried adding the same column twice, taking out the TextBox2 i just cant get it to work. all that works is if i take the last value out and the last column otherwise it will not work at all and i have now idea why.what i want is it to place a check mark in there to along with the name. code:

Dim SqlText As String = "INSERT INTO tblEmployeeNames ([EmployeeName], 
        [UseForDropDown]) VALUES ('" & Trim(TextBox1.Text) & " " & 
         Trim(TextBox2.Text) & " " & (CheckBox1.Checked) & "')"
Ňɏssa Pøngjǣrdenlarp
  • 38,411
  • 12
  • 59
  • 178
  • 4
    You have a SQL injection vulnerability. – SLaks May 16 '14 at 19:32
  • Remember to never hire [Bobby Tables](http://stackoverflow.com/questions/332365/how-does-the-sql-injection-from-the-bobby-tables-xkcd-comic-work) – Steve May 16 '14 at 19:39

1 Answers1

1

You have included the checkbox-state with the first value, you need to separate them with a comma.

Dim SqlText As String = "INSERT INTO tblEmployeeNames ([EmployeeName], [UseForDropDown]) VALUES ('" & Trim(TextBox1.Text) & " " & Trim(TextBox2.Text) & "', " & (CheckBox1.Checked))"

Notice the Checked state doesn't require apostrophes around it.

See SLaks comment as well, you should be using parameterized queries.

Andy G
  • 19,232
  • 5
  • 47
  • 69
  • 1
    Beat me to it. BTW, looks like you put a '.' instead of a ',' in your answer. – zeroef May 16 '14 at 19:35
  • ok so i have taken the whole thing apart tried it again tried adding your code ... nothing maybe i was unclear about what i was writing in its vb.net – user3389158 May 16 '14 at 19:48
  • Perhaps you should add to your question the whole code around this string and how do you use it – Steve May 16 '14 at 19:55