Click here to Skip to main content
16,017,707 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hello,i have a two fields Person and Incentive when i want to save this information in database when my output is comes in commamd prompt how can i do this?

What I have tried:

Write a program that add data in database when output is comes
Posted
Updated 1-May-16 20:53pm

1 solution

Read the data from your user - that's trivial, you know how to do that.
Then:
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
 
Comments
CPallini 2-May-16 2:58am    
5.

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