0

Hey Guys,

I'm connecting to an SQL server and updating some fields. This works:

cmd = new SqlCommand("UPDATE Laptops SET Checkout_Date = '" + form_CheckOut.checkout + "' WHERE name='pen-laptop1'", conn);
cmd.ExecuteNonQuery();

But this one doesn't:

cmd = new SqlCommand("UPDATE Laptops SET " +
" isCheckedOut = 0" +
" Checkout_Date = '" + form_CheckOut.checkout + 
"', Checkin_Date = '" + form_CheckOut.checkin +
"', Checked_Out_By = '" + form_CheckOut.user + 
"', WHERE name = 'pen-laptop1'");

cmd.ExecuteNonQuery();

EDIT - FIXED CODE BELOW

cmd = new SqlCommand("UPDATE Laptops SET isCheckedOut = 0" +
                    ", Checkout_Date = '" + form_CheckOut.checkout + 
                    "', Checkin_Date = '" + form_CheckOut.checkin +
                    "', Checked_Out_By = '" + form_CheckOut.user + 
                    "' WHERE Name = '" + name + "'", conn);

Edited by Duki: n/a

2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by Duki
0

NEVERMIND - didn't have ,conn);

Edited my previous post :)

Edited by Duki: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.