writing to database
- From: childtobe@xxxxxxxxx
- Date: 5 Apr 2007 03:07:48 -0700
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 :p)
.
- Follow-Ups:
- Re: writing to database
- From: Martin Ambuhl
- Re: writing to database
- From: Richard Bos
- Re: writing to database
- From: Ian Collins
- Re: writing to database
- Prev by Date: Re: K&R2 1.6 Arrays, exercise 1-13 (vertical histogram)
- Next by Date: cant reove the shift reduce conflict..
- Previous by thread: c doubt
- Next by thread: Re: writing to database
- Index(es):