Click here to Skip to main content
16,014,666 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
DateTime thisday = DateTime.Now;
    MySqlConnection con = new MySqlConnection("Server=localhost;UID=root;Database=db_cignal");
    con.Open();
    MySqlCommand cmd = con.CreateCommand();
    cmd.CommandText = "insert into revenue(Year,Newsales,Beginninginventory,Purchases,Goodforsales,Endinventory,Costofsales,Salesandwages,sss,Rental,Postage,Lightandwater,Freight,Fuel,Officesupplies,Taxesandlicenses,Representation,Depreciation,Transportation,Repairs,Miscellaneous,Totaloperatingexpense,Provisions,Netincomefinal)values(@one,@two,@three,@four,@five,@six,@seven,@eight,@nine,@ten,@eleven,@twelve,@thirteen,@fourteen,@fifteen,@sixteen,@seventeen,@eighteen,@nineteen,@twenty,@twentyone,@twentytwo,@twentythree,@twenthfour,@twentyfive)";
    cmd.Parameters.AddWithValue("@one", thisday.ToString("d"));
    cmd.Parameters.AddWithValue("@two", TotalPriceQuery());

private void TotalPriceQuery()
{
    MySqlConnection con = new MySqlConnection("Server=localhost;UID=root;Database=db_cignal");
    con.Open();
    MySqlCommand cmd = con.CreateCommand();
    cmd.CommandText = "SELECT SUM(TotalPrice) FROM inventoryout";
    cmd.Prepare();
    cmd.ExecuteNonQuery();
    con.Close();

}

i know its wrong but i hope you get my point :)
Posted
v2

You have many issues here.

1. Question is not clear.
2. You have many parameters defined, but passing only two. Not sure if you are passing others.
2. For the parameter @two, you are assigning a method, whose return type is void.
 
Share this answer
 
So what i wanted to do here is in the sales column, the value to be stored in the database in the sales table is the sum of all total price in inventoryout table
 
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