bkedersha Posted October 7, 2005 Posted October 7, 2005 I need to have an asp:checkbox place a "1", when it is checked, in a field in my sql server database or place a "0" when it is not checked. I started with this: Sub DoQuarterlyOverWrite(sender As Object, e As EventArgs) If Quaterly.Checked=true Then Quarterly.checked = "1" Else Quarterly.Checked = "0" End If End Sub I need to use this SQL insert because that is what the older developer used for this page. dim Cmd as new SQLCommand("InsertNewGrant",conn) cmd.CommandType = CommandType.StoredProcedure cmd.Parameters.Add("@GrantNumber", GrantNumber.Text.Trim()) cmd.Parameters.Add("@GrantProjectName", ProjectName.Text.Trim()) cmd.Parameters.Add("@CountryId", Country.SelectedItem.Value) cmd.Parameters.Add("@Description", 0) cmd.Parameters.Add("@CreateUserId", lblLoggedInAsId.text.Trim()) cmd.Parameters.Add("@UpdateUserId", 0) cmd.Parameters.Add("@ObligationDate", ObligationDate.SelectedDate) cmd.Parameters.Add("@OrigionalExpDate", CurrentExpirationDate.SelectedDate) cmd.Parameters.Add("@CurrentExpDate", CurrentExpirationDate.SelectedDate) cmd.Parameters.Add("@Terminated", 0) cmd.Parameters.Add("@Suspended", 0) cmd.Parameters.Add("@Locked", 0) cmd.Parameters.Add("@LockedByUserId", 0) cmd.Parameters.Add("@ACTNumber", 0) cmd.Parameters.Add("@GranteeName", GranteeName.Text.Trim()) cmd.Parameters.Add("@GranteeAddress1", AddressLine1.Text.Trim()) cmd.Parameters.Add("@GranteeAddress2", AddressLine2.Text.Trim()) cmd.Parameters.Add("@GranteeAddress3", AddressLine3.Text.Trim()) Cmd.connection.open() Cmd.ExecuteNonQuery() Cmd.connection.close() Help! :confused: :confused: :confused: :confused: Quote
kahlua001 Posted October 7, 2005 Posted October 7, 2005 the Stored Procedure needs to be modified so it takes int a @Quarterly parameter and the insert statment needs to insert this value. Then you need to add this paramter into your command object. Also, your if statment should look something like this.. If Quartherly.Checked Then cmd.Parameters.Add("@Quarterly", 1) Else cmd.Parameters.Add("@Quarterly", 0) Enf If Quote
bri189a Posted October 8, 2005 Posted October 8, 2005 Or you could: cmd.Parameters.Add("@Quarterly", Convert.ToInt(Quarterly.Checked)) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.