Click here to Skip to main content
15,895,142 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Trouble with IF...Then...ElseIf... Pin
big_D8-Jan-14 7:44
big_D8-Jan-14 7:44 
QuestionDatagridView not display any data Pin
Biplob Singha Shee6-Jan-14 7:41
Biplob Singha Shee6-Jan-14 7:41 
AnswerRe: DatagridView not display any data Pin
Dave Kreskowiak6-Jan-14 7:55
mveDave Kreskowiak6-Jan-14 7:55 
AnswerRe: DatagridView not display any data Pin
Ron Beyer6-Jan-14 7:58
professionalRon Beyer6-Jan-14 7:58 
GeneralRe: DatagridView not display any data Pin
Biplob Singha Shee6-Jan-14 8:37
Biplob Singha Shee6-Jan-14 8:37 
GeneralRe: DatagridView not display any data Pin
Ron Beyer6-Jan-14 8:58
professionalRon Beyer6-Jan-14 8:58 
GeneralRe: DatagridView not display any data Pin
Biplob Singha Shee6-Jan-14 9:24
Biplob Singha Shee6-Jan-14 9:24 
GeneralRe: DatagridView not display any data Pin
Biplob Singha Shee9-Jan-14 4:56
Biplob Singha Shee9-Jan-14 4:56 
Hi Ron,

I have tried parameterized queries as stated but facing some problems. Sometimes it displays data and sometimes not (May be it is wrong in my code). However, I've changed a field in my MySQL Database. I changed the Date field from Date datatype to Char(10) in both Income and Expenditure Table. Below I am giving the structure(SQL) of both the tables with data.

SQL
-- Table structure for table `expenditure`
--

DROP TABLE IF EXISTS `expenditure`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `expenditure` (
  `ExpId` int(11) NOT NULL AUTO_INCREMENT,
  `ExpDate` char(10) DEFAULT NULL,
  `ExpPurpose` varchar(350) DEFAULT NULL,
  `ExpRefNo` varchar(50) DEFAULT NULL,
  `Expenditure` double(10,2) DEFAULT '0.00',
  `ExpFlag` char(10) DEFAULT NULL,
  PRIMARY KEY (`ExpId`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `expenditure`
--

LOCK TABLES `expenditure` WRITE;
/*!40000 ALTER TABLE `expenditure` DISABLE KEYS */;
INSERT INTO `expenditure` VALUES (1,'06-01-2014','Purchase','ttyu76',15750.00,'P');
/*!40000 ALTER TABLE `expenditure` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `income`
--

DROP TABLE IF EXISTS `income`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `income` (
  `IncId` int(11) NOT NULL AUTO_INCREMENT,
  `IncDate` char(10) DEFAULT NULL,
  `IncPurpose` varchar(350) DEFAULT NULL,
  `IncRefNo` varchar(50) DEFAULT NULL,
  `IncIncome` double(10,2) DEFAULT '0.00',
  `IncFlag` char(2) DEFAULT NULL,
  PRIMARY KEY (`IncId`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `income`
--

LOCK TABLES `income` WRITE;
/*!40000 ALTER TABLE `income` DISABLE KEYS */;
INSERT INTO `income` VALUES (1,'06-01-2014','Sale','GE-INV/13-14/0102',1199.00,'S'),(2,'25-12-2013','Sale','GE-INV/13-14/0103',2875.00,'S'),(3,'09-01-2014','Sale','GE-INV/13-14/0104',343.00,'S'),(4,'08-01-2014','Sale','GE-INV/13-14/0105',118.00,'S');
/*!40000 ALTER TABLE `income` ENABLE KEYS */;
UNLOCK TABLES;


Now I am giving the VB.NET Code for report generation...
VB
Private Sub GenerateReport()
    Dim DateFrom As String = Convert.ToDateTime(DtpFrom.Value).ToString("dd-MM-yyyy")
    Dim DateTo As String = Convert.ToDateTime(DtpTo.Value).ToString("dd-MM-yyyy")

    Try
        OpenConnection()


        '// Retrieve the income details
        Try
            Dim sb As New StringBuilder '<--------------------------------------------------------------------- Table Income
            sb.Append("SELECT * FROM income WHERE IncDate BETWEEN '" & DateFrom & "' AND '" & DateTo & "' ORDER BY IncDate ASC")
            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 Expenditure
            sb1.Append("SELECT * FROM expenditure WHERE ExpDate BETWEEN '" & DateFrom & "' AND '" & DateTo & "' ORDER BY ExpDate ASC")
            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)

            Dim objRpt1 As New InEx
            objRpt1.SetDataSource(sdata.Tables(0))
            FormReport.RptViewer.ReportSource = objRpt1
            FormReport.ShowDialog()
            FormReport.RptViewer.RefreshReport()

        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    Catch ex As Exception
        MsgBox(ex.Message)
    Finally
        CloseConnection()
    End Try
End Sub


As you can see the Income table has 4 data and Expenditure table has just 1 data.
Amazingly, while I am generating the report from 01/12/2013 to 10/01/2014 [^], the report shows only 3 data (January 2014) from income table and 1 data from Expenditure table (It has only one data). But if I generate the report from 01/12/2013 to 31/12/2014 [^], the report shows all the data from the tables.

I am Completely Confused and unable to find the solution. I debug and found my select statements are returning data that are showing in the report.

Please help me.
GeneralRe: DatagridView not display any data Pin
Ron Beyer9-Jan-14 5:13
professionalRon Beyer9-Jan-14 5:13 
GeneralRe: DatagridView not display any data Pin
Biplob Singha Shee9-Jan-14 6:28
Biplob Singha Shee9-Jan-14 6:28 
GeneralRe: DatagridView not display any data Pin
Biplob Singha Shee9-Jan-14 6:32
Biplob Singha Shee9-Jan-14 6:32 
GeneralRe: DatagridView not display any data Pin
Biplob Singha Shee9-Jan-14 6:52
Biplob Singha Shee9-Jan-14 6:52 
GeneralRe: DatagridView not display any data Pin
Dave Kreskowiak6-Jan-14 9:21
mveDave Kreskowiak6-Jan-14 9:21 
GeneralRe: DatagridView not display any data Pin
Biplob Singha Shee6-Jan-14 9:27
Biplob Singha Shee6-Jan-14 9:27 
QuestionCOM component Pin
dharmendra113-Jan-14 20:01
dharmendra113-Jan-14 20:01 
AnswerRe: COM component Pin
Richard MacCutchan3-Jan-14 22:38
mveRichard MacCutchan3-Jan-14 22:38 
QuestionIncorporating setup with other EXEs Pin
SPSandy2-Jan-14 20:27
SPSandy2-Jan-14 20:27 
AnswerRe: Incorporating setup with other EXEs Pin
Bernhard Hiller2-Jan-14 21:50
Bernhard Hiller2-Jan-14 21:50 
GeneralRe: Incorporating setup with other EXEs Pin
SPSandy2-Jan-14 23:21
SPSandy2-Jan-14 23:21 
GeneralRe: Incorporating setup with other EXEs Pin
Heriberto Lugo5-Jan-14 20:14
Heriberto Lugo5-Jan-14 20:14 
QuestionRecovering VB.NET code Pin
Tim Carmichael2-Jan-14 7:37
Tim Carmichael2-Jan-14 7:37 
AnswerRe: Recovering VB.NET code Pin
Ron Beyer2-Jan-14 7:52
professionalRon Beyer2-Jan-14 7:52 
GeneralRe: Recovering VB.NET code Pin
Tim Carmichael2-Jan-14 8:36
Tim Carmichael2-Jan-14 8:36 
QuestionGraphics Pin
KanSanRag2-Jan-14 4:03
KanSanRag2-Jan-14 4:03 
AnswerRe: Graphics Pin
Chris Quinn2-Jan-14 5:03
Chris Quinn2-Jan-14 5:03 

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.