Click here to Skip to main content
15,892,809 members
Home / Discussions / Visual Basic
   

Visual Basic

 
Questioncoding for the following Pin
Member 119649636-Sep-15 23:43
Member 119649636-Sep-15 23:43 
AnswerRe: coding for the following Pin
Richard MacCutchan7-Sep-15 0:01
mveRichard MacCutchan7-Sep-15 0:01 
QuestionHow to Edit Return Masked number in Datagridveiw Pin
Mohamed Hamdy4-Sep-15 6:22
Mohamed Hamdy4-Sep-15 6:22 
SuggestionRe: How to Edit Return Masked number in Datagridveiw Pin
Richard MacCutchan4-Sep-15 6:51
mveRichard MacCutchan4-Sep-15 6:51 
AnswerRe: How to Edit Return Masked number in Datagridveiw Pin
Eddy Vluggen4-Sep-15 6:56
professionalEddy Vluggen4-Sep-15 6:56 
Questionhow do i hide the values in datagridview Pin
JackieRathinam3-Sep-15 19:49
JackieRathinam3-Sep-15 19:49 
AnswerRe: how do i hide the values in datagridview Pin
Eddy Vluggen4-Sep-15 5:17
professionalEddy Vluggen4-Sep-15 5:17 
QuestionMerging 3 identical datatables and summing a column in vb.net Pin
Vijay Kumar3-Sep-15 1:25
Vijay Kumar3-Sep-15 1:25 
I have 5 datatables which having each 3 columns (ID, Brand, Quanitiy) to derive the opening, purchase, sales and closing stock. The First 3 datatables should be merged and sum up to derive the opening stock as on given period. 4 th datatable is for Purchases done for the given period. The last one Datatable is for Sales done for the given period.

Here is my question: 1. How can i merge the 3 datatables and using the first 2 columns and summing the values? 2. How can i use the tables in crystal reports?
VB
Dim con As New ClassConnection 
If con.Conn.State = ConnectionState.Closed Then con.Conn.Open()

'To get Opening Stock in Full Quantity
    Dim sql As String = "SELECT tblBrand.B_ID AS ID, tblBrand.B_Name AS Brand," & _
    " Sum (tblOp_Details.Net_Qty) AS Quantity FROM tblOp_Stock INNER JOIN (tblBrand INNER JOIN" & _
    " tblOp_Details ON tblBrand.B_ID = tblOp_Details.B_ID) ON tblOp_Stock.Stk_ID = tblOp_Details.Stk_ID" & _
    " WHERE tblOp_Stock.God_ID = @GID GROUP BY tblBrand.B_ID, tblBrand.B_Name"

    'To get Purchases < start date and adding to the opening stock
    Dim sql1 As String = "SELECT tblBrand.B_ID AS ID, tblBrand.B_Name AS Brand," & _
    " Sum (tblPur_Details.Net_Qty) AS Quantity FROM tblPurchase INNER JOIN (tblBrand INNER JOIN" & _
    " tblPur_Details ON tblBrand.B_ID = tblPur_Details.B_ID) ON tblPurchase.Pur_ID = tblPur_Details.Pur_ID" & _
    " WHERE tblPurchase.God_ID = @GID AND tblPurchase.Rec_Date < @SDate GROUP BY tblBrand.B_ID, tblBrand.B_Name"

    'To get Sales < Start date and subtracting to the above
    Dim sql2 As String = "SELECT tblBrand.B_ID AS ID, tblBrand.B_Name AS Brand," & _
    " Sum (tblSales_Details.Net_Qty) AS Quantity FROM tblSales INNER JOIN (tblBrand INNER JOIN" & _
    " tblSales_Details ON tblBrand.B_ID = tblSales_Details.B_ID) ON tblSales.Sale_ID = tblSales_Details.Sale_ID" & _
    " WHERE tblSales.God_ID = @GID AND tblSales.Sale_Date < @SDate GROUP BY tblBrand.B_ID, tblBrand.B_Name"
    'The above 3 condition is for deriving opening stock as on given date

    'To get Purchases >= Start Date and <= Start Date
    Dim sql3 As String = "SELECT tblBrand.B_ID AS ID, tblBrand.B_Name AS Brand," & _
    " Sum(tblPur_Details.Net_Qty) AS Quantity FROM tblBrand INNER JOIN (tblPurchase INNER JOIN" & _
    " tblPur_Details ON tblPurchase.Pur_ID = tblPur_Details.Pur_ID) ON tblBrand.B_ID = tblPur_Details.B_ID" & _
    " WHERE tblPurchase.God_ID = @GID And tblPurchase.Rec_Date >= @SDate And tblPurchase.Rec_Date" & _
    " <= @EDate GROUP BY tblBrand.B_ID, tblBrand.B_Name"
    'The above condition is for deriving Purchases as on given date

'To get Sales >= Start Date and <= Start Date
    Dim sql4 As String = "SELECT tblBrand.B_ID AS ID, tblBrand.B_Name AS Brand," & _
    " Sum(tblSales_Details.Net_Qty) AS Quantity FROM tblBrand INNER JOIN (tblSales INNER JOIN" & _
    " tblSales_Details ON tblSales.Sale_ID = tblSales_Details.Sale_ID) ON tblBrand.B_ID = tblSales_Details.B_ID" & _
    " WHERE tblSales.God_ID = @GID And tblSales.Sale_Date >= @SDate And tblSales.Sale_Date <= @EDate" & _
    " And tblSales_Details.S_Active = @SAct GROUP BY tblBrand.B_ID, tblBrand.B_Name"
    'The above condition is for deriving Sales as on given date

    Dim da As New OleDb.OleDbDataAdapter(sql, con.Conn)
    Dim da1 As New OleDb.OleDbDataAdapter(sql1, con.Conn)
    Dim da2 As New OleDb.OleDbDataAdapter(sql2, con.Conn)
    Dim da3 As New OleDb.OleDbDataAdapter(sql3, con.Conn)
    Dim da4 As New OleDb.OleDbDataAdapter(sql4, con.Conn)

    da.SelectCommand.Parameters.AddWithValue("@GID", Me.stBar_G_ID.Text)
    da1.SelectCommand.Parameters.AddWithValue("@GID", Me.stBar_G_ID.Text)
    da1.SelectCommand.Parameters.AddWithValue("@SDate", Me.dtpStart.ToString)
    da2.SelectCommand.Parameters.AddWithValue("@GID", Me.stBar_G_ID.Text)
    da2.SelectCommand.Parameters.AddWithValue("@SDate", Me.dtpStart.ToString)
    da3.SelectCommand.Parameters.AddWithValue("@GID", Me.stBar_G_ID.Text)
    da3.SelectCommand.Parameters.AddWithValue("@SDate", Me.dtpStart.ToString)
    da3.SelectCommand.Parameters.AddWithValue("@EDate", Me.dtpEnd.ToString)
    da4.SelectCommand.Parameters.AddWithValue("@GID", Me.stBar_G_ID.Text)
    da4.SelectCommand.Parameters.AddWithValue("@SDate", Me.dtpStart.ToString)
    da4.SelectCommand.Parameters.AddWithValue("@EDate", Me.dtpEnd.ToString)
    da4.SelectCommand.Parameters.AddWithValue("@SAct", "Yes")

    Dim dt As New DataTable
    Dim dt1 As New DataTable
    Dim dt2 As New DataTable
    Dim dt3 As New DataTable
    Dim dt4 As New DataTable


Thanks in advance.
QuestionCompare two table Pin
dha NAA3-Sep-15 0:46
dha NAA3-Sep-15 0:46 
AnswerRe: Compare two table Pin
Ralf Meier3-Sep-15 1:51
mveRalf Meier3-Sep-15 1:51 
GeneralRe: Compare two table Pin
dha NAA3-Sep-15 3:24
dha NAA3-Sep-15 3:24 
AnswerRe: Compare two table Pin
Richard Deeming3-Sep-15 2:54
mveRichard Deeming3-Sep-15 2:54 
GeneralRe: Compare two table Pin
dha NAA3-Sep-15 3:24
dha NAA3-Sep-15 3:24 
GeneralDesign question about access to database. Pin
Member 116832511-Sep-15 22:34
Member 116832511-Sep-15 22:34 
GeneralRe: Design question about access to database. Pin
CHill602-Sep-15 6:02
mveCHill602-Sep-15 6:02 
GeneralRe: Design question about access to database. Pin
Member 116832513-Sep-15 1:38
Member 116832513-Sep-15 1:38 
GeneralRe: Design question about access to database. Pin
GuyThiebaut3-Sep-15 0:04
professionalGuyThiebaut3-Sep-15 0:04 
GeneralRe: Design question about access to database. Pin
Member 116832513-Sep-15 1:28
Member 116832513-Sep-15 1:28 
GeneralRe: Design question about access to database. Pin
GuyThiebaut3-Sep-15 1:40
professionalGuyThiebaut3-Sep-15 1:40 
GeneralRe: Design question about access to database. Pin
Member 116832513-Sep-15 1:47
Member 116832513-Sep-15 1:47 
GeneralRe: Design question about access to database. Pin
GuyThiebaut3-Sep-15 1:57
professionalGuyThiebaut3-Sep-15 1:57 
GeneralRe: Design question about access to database. Pin
Member 116832513-Sep-15 2:19
Member 116832513-Sep-15 2:19 
GeneralRe: Design question about access to database. Pin
GuyThiebaut3-Sep-15 2:25
professionalGuyThiebaut3-Sep-15 2:25 
Questioninsert one data table to another Pin
dha NAA1-Sep-15 19:10
dha NAA1-Sep-15 19:10 
AnswerRe: insert one data table to another Pin
Wendelius1-Sep-15 19:50
mentorWendelius1-Sep-15 19:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.