Click here to Skip to main content
15,891,828 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: barcode generator Pin
David Mujica17-Dec-13 3:34
David Mujica17-Dec-13 3:34 
QuestionBest way to save data in Visual basic Pin
HimanshuSha17-Dec-13 1:45
HimanshuSha17-Dec-13 1:45 
AnswerRe: Best way to save data in Visual basic Pin
Tim Carmichael17-Dec-13 2:13
Tim Carmichael17-Dec-13 2:13 
GeneralRe: Best way to save data in Visual basic Pin
HimanshuSha17-Dec-13 2:30
HimanshuSha17-Dec-13 2:30 
GeneralRe: Best way to save data in Visual basic Pin
Dave Kreskowiak17-Dec-13 2:49
mveDave Kreskowiak17-Dec-13 2:49 
GeneralRe: Best way to save data in Visual basic Pin
HimanshuSha17-Dec-13 21:04
HimanshuSha17-Dec-13 21:04 
GeneralRe: Best way to save data in Visual basic Pin
Dave Kreskowiak18-Dec-13 6:32
mveDave Kreskowiak18-Dec-13 6:32 
QuestionCreating an Income and Expenditure Statement. Pin
Biplob Singha Shee16-Dec-13 21:38
Biplob Singha Shee16-Dec-13 21:38 
Hi all,

I want to create an Income and Expenditure Statement in Crystal Report (I am using VB.NET 2010, MySQL and Crystal Report with XML datasource). I have two different tables namely
1. income
2. expenditure

Structure of income table is...
--------------------------------------------------------------
|  ID   |   IncomeDate   |  Details         |  IncomeAmt     |
-------------------------------------------------------------
|  a1   |  2/12/2013     | Sale to Mr. ABC  |      34,000.00 |
|  a2   |  3/12/2013     | Sale to Mr. DEF  |      14,000.00 |
|  a3   |  4/12/2013     | Sale to Mr. IJK  |      22,500.00 |
|  a4   |  5/12/2013     | Sale to Mr. LMN  |       1,500.00 |
|  a5   |  6/12/2013     | Sale to Mr. OPQ  |       9,235.00 |
|  a6   |  7/12/2013     | Sale to Mr. RST  |      66,000.00 |
--------------------------------------------------------------

In the above table Mr. ABC, DEF, IJK are all different customers.
and Structure of expenditure table is
--------------------------------------------------------------
|  ID   |   ExpDate      |  Details            |  ExpAmt     |
--------------------------------------------------------------
|  b1   |  1/12/2013     | Purchase from  ABC  |   34,000.00 |
|  b2   |  10/12/2013    | Purchase from  DEF  |   14,000.00 |
|  b3   |  11/12/2013    | Purchase from  IJK  |   22,500.00 |
|  b4   |  16/12/2013    | Purchase from  LMN  |    1,500.00 |
|  b5   |  26/12/2013    | Purchase from  OPQ  |    9,235.00 |
|  b6   |  27/12/2013    | Purchase from  RST  |   66,000.00 |
--------------------------------------------------------------

In the above table ABC, DEF, IJK are all different distributors.
The above tables are completely different although the structures are almost same. But data is different.
I want to create the report...
---------------------------------------------------||---------------------------------------------------
| ID | IncomeDate |  Details         | IncomeAmt | || ID | ExpDate    |  Details           | ExpAmt    |
---------------------------------------------------||---------------------------------------------------
| a1 | 2/12/2013  | Sale to Mr. ABC  | 34,000.00 | || b1 | 1/12/2013  | Purchase from  ABC | 34,000.00 |
| a2 | 3/12/2013  | Sale to Mr. DEF  | 14,000.00 | || b2 | 10/12/2013 | Purchase from  DEF | 14,000.00 |
| a3 | 4/12/2013  | Sale to Mr. IJK  | 22,500.00 | || b3 | 11/12/2013 | Purchase from  IJK | 22,500.00 |
| a4 | 5/12/2013  | Sale to Mr. LMN  |  1,500.00 | || b4 | 16/12/2013 | Purchase from  LMN |  1,500.00 |
| a5 | 6/12/2013  | Sale to Mr. OPQ  |  9,235.00 | || b5 | 26/12/2013 | Purchase from  OPQ |  9,235.00 |
| a6 | 7/12/2013  | Sale to Mr. RST  | 66,000.00 | || b6 | 27/12/2013 | Purchase from  RST | 66,000.00 |
---------------------------------------------------||---------------------------------------------------

I have 3 options.

1. Join two tabels using mysql join/union/union all or other possible commands,
2. Create two XML files of two different tables and merge them,
3. Crystal Report DataSource has two different XML tables.

I tried all, but failed.

my code for option 1 is...
VB
            Try
OpenConnection
                Dim sb As New StringBuilder '<--------------------------------------------------------------------- Table 1
                sb.Append("SELECT * FROM income WHERE income.IncDate BETWEEN '" & DateFrom & "' AND '" & DateTo & "' UNION SELECT * FROM expenditure WHERE expenditure.ExpDate BETWEEN '" & DateFrom & "' AND '" & DateTo & "'")
                Dim dbcommand As New MySqlCommand
                Dim dbadapter As New MySqlDataAdapter
                Dim stdata As New DataSet()
                dbcommand.Connection = conn
                dbcommand.CommandText = sb.ToString
                dbadapter.SelectCommand = dbcommand
                dbadapter.Fill(stdata)
                stdata.WriteXml(Application.StartupPath & "\ReportXml\IncomeExpenditure.xml", XmlWriteMode.WriteSchema)
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try

and for option 2 is...
VB
'// Retrieve the income details
            Try
                Dim sb As New StringBuilder '<--------------------------------------------------------------------- Table 1
                sb.Append("SELECT * FROM income WHERE IncDate BETWEEN '" & DateFrom & "' AND '" & DateTo & "'")
                Dim dbcommand As New MySqlCommand
                Dim dbadapter As New MySqlDataAdapter
                Dim stdata As New DataSet()
                dbcommand.Connection = conn
                dbcommand.CommandText = sb.ToString
                dbadapter.SelectCommand = dbcommand
                dbadapter.Fill(stdata)
                stdata.WriteXml(Application.StartupPath & "\ReportXml\Income.xml", XmlWriteMode.WriteSchema)
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try


            '// Retrieve the Expenditure details
            Try
                Dim sb1 As New StringBuilder '<--------------------------------------------------------------------- Table 2
                sb1.Append("SELECT * FROM expenditure WHERE ExpDate BETWEEN '" & DateFrom & "' AND '" & DateTo & "'")
                Dim dcommand As New MySqlCommand
                Dim dadapter As New MySqlDataAdapter
                Dim sdata As New DataSet()
                dcommand.Connection = conn
                dcommand.CommandText = sb1.ToString
                dadapter.SelectCommand = dcommand
                dadapter.Fill(sdata)
                sdata.WriteXml(Application.StartupPath & "\ReportXml\Expenditure.xml", XmlWriteMode.WriteSchema)
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try


            '// Merge Into One (Two XML Files)  <---------------------------------------------------------- Table 1 + Table2 = Merge1
            Dim Table1 As New XmlTextReader(Application.StartupPath & "\ReportXml\Income.xml")
            Dim Table2 As New XmlTextReader(Application.StartupPath & "\ReportXml\Expenditure.xml")
            Dim XmlDataSet1 As New DataSet
            Try
                XmlDataSet1.ReadXml(Table1)
                Dim XmlDataSet2 As New DataSet
                XmlDataSet2.ReadXml(Table2)

                XmlDataSet1.Merge(XmlDataSet2)
                XmlDataSet1.WriteXml(Application.StartupPath & "\ReportXml\IncomeExpenditure.xml", XmlWriteMode.WriteSchema)
            Catch ex As Exception
                MsgBox(ex.Message, MsgBoxStyle.Critical, "Error!!!")
            End Try


But not getting my expected result. I tried to find the solutions in the internet but everywhere I found, at least one matching column should be there to join/merge. But I want to simply join these two tables side by side. One more thing to do. I want to show the result filtering between two dates.

What should I do ?
Biplob.

AnswerRe: Creating an Income and Expenditure Statement. Pin
Mycroft Holmes17-Dec-13 0:09
professionalMycroft Holmes17-Dec-13 0:09 
GeneralRe: Creating an Income and Expenditure Statement. Pin
Biplob Singha Shee17-Dec-13 9:37
Biplob Singha Shee17-Dec-13 9:37 
AnswerRe: Creating an Income and Expenditure Statement. Pin
David Mujica17-Dec-13 2:08
David Mujica17-Dec-13 2:08 
AnswerRe: Creating an Income and Expenditure Statement. Pin
kmoorevs24-Dec-13 7:18
kmoorevs24-Dec-13 7:18 
QuestionLoading data from SQL server Pin
Member 1038849415-Dec-13 12:25
Member 1038849415-Dec-13 12:25 
AnswerRe: Loading data from SQL server Pin
Member 1038849415-Dec-13 12:33
Member 1038849415-Dec-13 12:33 
GeneralRe: Loading data from SQL server Pin
Eddy Vluggen16-Dec-13 7:10
professionalEddy Vluggen16-Dec-13 7:10 
GeneralRe: Loading data from SQL server Pin
Member 1038849418-Dec-13 3:27
Member 1038849418-Dec-13 3:27 
QuestionDelete using BindingContext Pin
Member 1038849415-Dec-13 10:36
Member 1038849415-Dec-13 10:36 
AnswerRe: Delete using BindingContext Pin
Mycroft Holmes15-Dec-13 11:50
professionalMycroft Holmes15-Dec-13 11:50 
Questionview image from a picturebox loading from a database Pin
waner michaud15-Dec-13 10:15
waner michaud15-Dec-13 10:15 
AnswerRe: view image from a picturebox loading from a database Pin
Mycroft Holmes15-Dec-13 11:47
professionalMycroft Holmes15-Dec-13 11:47 
GeneralRe: view image from a picturebox loading from a database Pin
waner michaud19-Dec-13 4:36
waner michaud19-Dec-13 4:36 
QuestionCustom paper size Problem in Dot matrix printer... Pin
digitalbalu13-Dec-13 16:17
digitalbalu13-Dec-13 16:17 
QuestionLogic for Sales Return and Purchase Return Pin
Biplob Singha Shee13-Dec-13 7:10
Biplob Singha Shee13-Dec-13 7:10 
AnswerRe: Logic for Sales Return and Purchase Return Pin
Mycroft Holmes13-Dec-13 12:38
professionalMycroft Holmes13-Dec-13 12:38 
GeneralRe: Logic for Sales Return and Purchase Return Pin
Biplob Singha Shee14-Dec-13 8:56
Biplob Singha Shee14-Dec-13 8:56 

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.