troubleshooting Question

i need to compare in the products table and actions table

Avatar of Tech_Men
Tech_MenFlag for Israel asked on
2 Comments1 Solution208 ViewsLast Modified:
i need to do this :

in my products table i have for each product unit in stock alarm for exsample

UnitKey    |MinInStock
1000            100
now i have a ActionTable whit all the products Qunataty in the stock
if the Product quantity is less from the MinInStock
i need to get message i have tryd to do this like that :



                        SqlConnection NewConn = new SqlConnection();


                        IDbCommand cmd1 = this.sqlConnection1.CreateCommand();
                        IDbCommand cmd2 = this.sqlConnection2.CreateCommand();

                        cmd1.CommandText = "SELECT * FROM Products";
                        cmd2.CommandText = "Select * From VIEW1";

                        IDbCommand CmdGetTotalByCode=NewConn.CreateCommand();
                        IDbCommand CmdgetHatByCode = NewConn.CreateCommand();

                        CmdGetTotalByCode.CommandText="SELECT SUM(Kamot) AS ParitTotal FROM Actions WHERE (CodeParit = @CA)";
                        SqlParameter parm = new SqlParameter("@CA",SqlDbType.VarChar,50,"CodeParit");

                        CmdgetHatByCode.CommandText="SELECT ProMinimom FROM View1 WHERE (ProKey = @CA)";
                        SqlParameter parm1 = new SqlParameter("@CA",SqlDbType.VarChar,50,"ParitNum");
                        IDataReader reader = cmd1.ExecuteReader();
                        IDataReader reader1 = cmd2.ExecuteReader();
                        while (reader.Read())
                              string ProKey = reader["ProKey"].ToString();
                                    string Pkey=reader1["ProKey"].ToString();
                                    if (ProKey.ToString()==Pkey.ToString())
                                          string Degem=reader["ProKey"].ToString();
                                          int t=Int32.Parse(CmdGetTotalByCode.ExecuteScalar().ToString());
                                          int h=Int32.Parse(CmdgetHatByCode.ExecuteScalar().ToString());
                                          if (h>t)
                                                listBox1.Items.Add("ProKey" + Degem.ToString() + " " + "U need to order moreי");


but its dosent work well

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros