I am working on an inventory software in which I am placing order in my order panel, every thing is working absolutely fine, let me show you my database image:
and the code I used to enter data in DB is :
string sql = "";
int ProductQuantity = 0;
string ProductCode = "";
int ProductPrice = 0;
int totalPrice = 0;
string customerName;
for (int i = 0; i < lvProductInfo.Items.Count; i++)
{
ProductCode = Convert.ToString(lvProductInfo.Items[i].SubItems[1].Text);
ProductQuantity = Convert.ToInt32(lvProductInfo.Items[i].SubItems[2].Text);
ProductPrice = Convert.ToInt32(lvProductInfo.Items[i].SubItems[3].Text);
totalPrice = Convert.ToInt32(lvProductInfo.Items[i].SubItems[4].Text);
customerName = lvProductInfo.Items[i].SubItems[5].Text;
sql = "";
sql = "INSERT INTO PurchaseLog (ProductCode,ProductQuantity,ProductPrice,TotalPrice,CustomerName)"
+ " VALUES ('" + ProductCode + "','" + ProductQuantity + "','" + ProductPrice + "','" + totalPrice + "','" + customerName + "')";
clsConnection clsCn = new clsConnection();
SqlConnection cn = null;
SqlCommand cmd = new SqlCommand();
clsCn.fnc_ConnectToDB(ref cn);
cmd.Connection = cn;
cmd.CommandText = sql;
cmd.ExecuteNonQuery();
}
Now I want to add date and time also with all these data in my DB.