Why Does SQL Date Value Become NULL When Using AddWithValue?

15 hours ago 1
ARTICLE AD BOX
if (connection.State == ConnectionState.Closed) { connection.Open(); string signup = "INSERT INTO TABLE (ID,NAME,SURNAME,MAIL,PASSWORD) VALUES (@ID,@NAME,@SURNAME,@MAIL,@PASSWORD)"; SqlCommand command = new SqlCommand(signup, connection); command.Parameters.AddWithValue("@ID", ID.Text); command.Parameters.AddWithValue("@NAME", NAME.Text); command.Parameters.AddWithValue("@SURNAME", SURNAME.Text); command.Parameters.AddWithValue("@MAIL", MAIL.Text); command.Parameters.AddWithValue("@PASSWORD", PASSWORD.Text); command.Parameters.AddWithValue("@DATE",dateTimePicker11.Value); command.ExecuteNonQuery(); MessageBox.Show("REGISTRATION SUCCESSFUL", "Message", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); connection.Close(); }

I defined an SQL query like this, but the DATE value always returns null. How can I solve this problem?

Dale K's user avatar

Dale K

28.4k15 gold badges62 silver badges88 bronze badges

user32189599's user avatar

5

Read Entire Article