MysqlConn = New MySqlConnection MysqlConn.ConnectionString = "server=localhost;userid=root;database=stock_sales_system" Dim SDA As New MySqlDataAdapter Dim dbDataSet As New DataTable Dim bSource As New BindingSource Try MysqlConn.Open() Dim query As String query = "SELECT SUM(Quantity) AS Sold FROM invoice_products AS IP, invoice AS I WHERE ProductBarcode LIKE @ProductBarcode AND IP.InvoiceNumber = I.InvoiceNumber AND I.InvoiceDate >= @FromDate AND I.InvoiceDate <= @ToDate;" Command.Parameters.Add("@ProductBarcode", MySqlDbType.VarChar).Value = frmManageProducts.ProductTableAdapter.GetBarcode1(cbxProductName.Text) Command.Parameters.Add("@FromDate", MySqlDbType.Date).Value = dtpFrom.Value Command.Parameters.Add("@ToDate", MySqlDbType.Date).Value = dtpTo.Value Command = New MySqlCommand(query, MysqlConn) SDA.SelectCommand = Command SDA.Fill(dbDataSet) bSource.DataSource = dbDataSet DataGridView1.DataSource = bSource SDA.Update(dbDataSet) MysqlConn.Close() Catch ex As Exception MessageBox.Show(ex.Message) Finally MysqlConn.Dispose() End Try
Command.Parameters.Add("@ToDate", MySqlDbType.Date).Value = dtpTo.Value
query = "SELECT SUM(IP.Quantity) AS Sold FROM invoice_products AS IP INNER JOIN invoice AS I ON IP.InvoiceNumber = I.InvoiceNumber WHERE ProductBarcode LIKE @ProductBarcode AND I.InvoiceDate >= @FromDate AND I.InvoiceDate <= @ToDate"
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)