writing to database

Discussion in 'C++' started by Childtobe, Apr 5, 2007.

  1. Childtobe

    Childtobe Guest

    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)
    Childtobe, Apr 5, 2007
    #1
    1. Advertising

  2. Childtobe wrote:
    > 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?
    >
    > [..]


    What in the world makes you think that C# or databases are topical
    here in comp.lang.c++?
    Victor Bazarov, Apr 5, 2007
    #2
    1. Advertising

  3. Childtobe

    Ian Collins Guest

    Victor Bazarov wrote:
    > Childtobe wrote:
    >
    >>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?
    >>
    >>[..]

    >
    >
    > What in the world makes you think that C# or databases are topical
    > here in comp.lang.c++?
    >

    Probably the same thing that made him think they were topical on
    comp.lang.c!

    --
    Ian Collins.
    Ian Collins, Apr 5, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Erik
    Replies:
    2
    Views:
    358
  2. Netfreaky

    writing quotes to database

    Netfreaky, May 18, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    371
    Curt_C [MVP]
    May 18, 2004
  3. HNguyen
    Replies:
    4
    Views:
    2,388
    HNguyen
    Dec 21, 2004
  4. =?Utf-8?B?cG11ZA==?=
    Replies:
    1
    Views:
    597
    bruce barker
    Dec 28, 2004
  5. Sparky Arbuckle

    Data Not Writing to Database

    Sparky Arbuckle, Feb 27, 2005, in forum: ASP .Net
    Replies:
    6
    Views:
    316
    Patrick Olurotimi Ige
    Feb 28, 2005
Loading...

Share This Page