2
Answers

Inserting Data

Forgottenhart

Forgottenhart

17y
2.3k
1

The code below is for a button which needs to send data to a sql DB

I have two questions:

1 Does anyone have a sample code snippet that i can look at to see how to do this

2 would it be better to pass the variables to a stored procedure
and have the DB do the insert
or
should i just code it in as an insert into


My initial instinct is to use a stored procedure as that would make it easier
to upgrade/change in the future if needed.


Code:

private void Submit_btn_Click_1(object sender, EventArgs e)
        {
            //submit data to the desc_table
            /*connecting to database to perform task
            *  connection variable. open();
            *   function
            * .close(); */

            myconnection.Open();
            //do stuff
            myconnection.Close();
        }


Thanks all in advance

Answers (2)