0

here is the code:

                Class1.GetDataSet("Select * from clients");
                string str = "INSERT INTO clients(Client_Id,Client_First_Name,Client_Last_Name,Client_Tel) VALUES('" + Customer_Id_TB.Text + "','" + Customer_First_Name.Text + "','" + Customer_Last_Name.Text + "','" + Customer_Tel.Text + "')";
                //שם את המזמין ברשימת הקליינטים
                Class1.GetDataSet(str);
                Class1.GetDataSet("select * from Sum_sell_Details");
                int Sell_Id= Convert.ToInt32(Class1.ds.Tables[0].Rows[Class1.ds.Tables[0].Rows.Count-1]["Sell_Id"].ToString());
                Sell_Id++;
                //בודק את מספר ההזמנה האחרון ומוסיף אחד כי זה מספר סידורי
                
                string h = "select [Product_Id] from [Product] where [product_Name]= '" + Product_Name_CB.SelectedItem.ToString() + "' ";
                //בודק את המספר הסידורי של המוצר לפי השם שלו
                Class1.GetDataSet(h);
                Class1.GetDataSet("Select * from Sum_Sell_Details");
                str = "INSERT INTO Sum_Sell_Details(Sell_Id,Product_Id,quantity) VALUES('" + Sell_Id + "','" + h + "','" + Quantity_TB.Text + "')";
                Class1.GetDataSet(str);
                string Product_Price = "select price from Product where Product_Name ='" + Product_Name_CB.SelectedItem.ToString() + "'";
                //מכניס את סיכום המכירה
                Class1.GetDataSet(Product_Price);
                Class1.GetDataSet("select * from product");
                int In = Convert.ToInt32(Class1.ds.Tables[0].Rows[0]["price"].ToString());
                int Tot_Price = In * Convert.ToInt32(Quantity_TB.Text);
                
                string worker_Id_SQL = "select Worker_Id where Worker_Name = '" + Worker_Name_CB.SelectedItem.ToString() + "'";
                Class1.GetDataSet(worker_Id_SQL);
                str = "INSERT INTO Sell(Sell_Id,Total_Price,Client_Id,date_sell,Worker_Id) VALUES('" + Sell_Id + "','" + Tot_Price + "','" + Customer_Id_TB.Text + "','"+ DateTime.Now+ "','"+ worker_Id_SQL+"')";
                Class1.GetDataSet(str);

It writes syntax error(missing operator) in query in every Select statement. I use Access Database. I'm new at this so it might be a dumb question.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • 2
    **Use proper parameterization**, otherwise you leave yourself open to SQL injection and syntax errors – Charlieface Apr 18 '21 at 08:11
  • If fields are number type, don't use apostrophe delimiters for inputs. Names make poor unique identifiers - what if there are two John Smith (or some other very common name)? – June7 Apr 18 '21 at 17:31

0 Answers0