dswett2
asked on
Sending a checkbox value to a stored procedure
I have a few bit columns in a table in a database. I have a stored procedure in which I pass values to create a record. I represent these bit values as checkboxes on my .aspx page. I'm looking to pass the state of these checkboxes (checked = 1, unchecked = 2) to my storedprocedure.
My existing vb code is below which is passing String values fine. I just need the syntax for the lines: ******DIM checkboxes (cb1, cb2, etc)************ and *******Add cb1, cb2 paremeters******
My existing vb code is below which is passing String values fine. I just need the syntax for the lines: ******DIM checkboxes (cb1, cb2, etc)************ and *******Add cb1, cb2 paremeters******
Dim connectionstring As String = System.Configuration.ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString
Dim ObjConn As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(connectionstring)
Dim objCmd As SqlCommand = New SqlCommand()
objCmd.Connection = ObjConn
Dim codereference As String = txtCodeReference.Text
Dim description As String = txtDescription.Text
Dim category As String = txtCategory.Text
******DIM checkboxes (cb1, cb2, etc)************
objCmd.CommandType = System.Data.CommandType.StoredProcedure
objCmd.CommandText = "dbo.AddInspectionToPicklist"
objCmd.Parameters.Add("@codereference", Data.SqlDbType.VarChar).Value = codereference
objCmd.Parameters.Add("@description", Data.SqlDbType.VarChar).Value = description
objCmd.Parameters.Add("@category", Data.SqlDbType.VarChar).Value = category
*******Add cb1, cb2 paremeters******
ObjConn.Open()
objCmd.ExecuteNonQuery()
ObjConn.Close()
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
A typo in the second If/EndIF block:
If (myCheckBox2.Checked = True) then
cb2 = 1 <==== Not cb12 = 1
Else
cb2 = 2
End If
If (myCheckBox2.Checked = True) then
cb2 = 1 <==== Not cb12 = 1
Else
cb2 = 2
End If
ASKER
perfect, thanks!
Otherwise, you would just add it like any other parameter.
Open in new window