C
Childtobe
Hi, i'm writing an enquete in C# and i need to write data to a
database.
I'm using stored procedures to do so. Now the problem: I have a
question with a checkboxlist, and the user can select multiple
answers. How do i write all of them to my database?
code: (VoerAntwoordCheckBoxListToe is the name of the stored
procedure)
protected void ButtonVerzenden4_Click(object sender, EventArgs e)
{
AntwoordenCS CheckBoxListAntwoord = new AntwoordenCS();
CheckBoxListAntwoord.VoerAntwoordCheckBoxListToe(
Convert.ToInt32(Request.QueryString["vraag_ID"]),
Convert.ToInt32(CheckBoxListVraag4.SelectedItem.Value));
Response.Redirect("Vragenlijst.aspx?vraag_ID=5", true);
stored procedure:
ALTER PROCEDURE [dbo].[VoerAntwoordCheckBoxListToe]
(
@VraagID int,
@KeuzeMogelijkheid int
)
AS
/* SET NOCOUNT ON */
INSERT INTO Antwoorden(antwoord_keuze, vraag_ID)
VALUES(@KeuzeMogelijkheid, @VraagID)
RETURN
With this code a can write the first selected anwser to the database.
Now the trick is to do this for the other selected answers....
thx in advance for your help (and sorry for the crapy english )
database.
I'm using stored procedures to do so. Now the problem: I have a
question with a checkboxlist, and the user can select multiple
answers. How do i write all of them to my database?
code: (VoerAntwoordCheckBoxListToe is the name of the stored
procedure)
protected void ButtonVerzenden4_Click(object sender, EventArgs e)
{
AntwoordenCS CheckBoxListAntwoord = new AntwoordenCS();
CheckBoxListAntwoord.VoerAntwoordCheckBoxListToe(
Convert.ToInt32(Request.QueryString["vraag_ID"]),
Convert.ToInt32(CheckBoxListVraag4.SelectedItem.Value));
Response.Redirect("Vragenlijst.aspx?vraag_ID=5", true);
stored procedure:
ALTER PROCEDURE [dbo].[VoerAntwoordCheckBoxListToe]
(
@VraagID int,
@KeuzeMogelijkheid int
)
AS
/* SET NOCOUNT ON */
INSERT INTO Antwoorden(antwoord_keuze, vraag_ID)
VALUES(@KeuzeMogelijkheid, @VraagID)
RETURN
With this code a can write the first selected anwser to the database.
Now the trick is to do this for the other selected answers....
thx in advance for your help (and sorry for the crapy english )