3 replies
by careed
To make this short, let's assume you have the webform designed and laid out. Given this, we have a CheckBox control with an ID of chkYN and a SQL Table (tblTest) that has two columns: TableID and YNResponse. Let's consider two scenarios for YNResponse: it is either a bit field or char(1) field. Given a stored procedure into SQL Server, then you could do the following as a parameter into your stored procedure, given ptrTest as the SQLParameter object and cmdTest as the SQLCommand object:
As a bit field:
ptrTest = new SqlParameter();
ptrTest.ParameterName = "@YNResponse";
ptrTest.SqlDbType = SqlDbType.Bit;
ptrTest.Value = chkYN.Checked;
cmdTest.Parameters.Add(ptrTest);
cmdTest.ExecuteNonQuery();
As a char(1) field:
ptrTest = new SqlParameter();
ptrTest.ParameterName = "@YNResponse";
ptrTest.SqlDbType = SqlDbType.Char;
ptrTest.Size = 1;
ptrTest.Value = chkYN.Checked ? "Y" : "N";
cmdTest.Parameters.Add(ptrTest);
cmdTest.ExecuteNonQuery();
Hope this helps!
by vhansen86
Poster rated this answer.
by vhansen86
This discussion is closed to new replies.
Trending Web Development posts
Sort by Trending