Click here to Skip to main content
15,887,303 members
Please Sign up or sign in to vote.
1.00/5 (6 votes)
See more:
iam new to data base integration. i want the data entered in the text box to be saved in a certain column of an access database and the database should load in a list box on running the application.
any ideas
thanks in advance

What I have tried:

i can load data from a database but cannot add data
Posted
Updated 18-May-16 3:45am

1 solution

Try:
C#
using (SqlConnection con = new SqlConnection(strConnect))
    {
    con.Open();
    using (SqlCommand cmd = new SqlCommand("INSERT INTO myTable (myColumn1, myColumn2) VALUES (@C1, @C2)", con))
        {
        cmd.Parameters.AddWithValue("@C1", myValueForColumn1);
        cmd.Parameters.AddWithValue("@C2", myValueForColumn2);
        cmd.ExecuteNonQuery();
        }
    }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900