i have chart and i want fill it by searching between 2 dates ( my database is MS Access 2003 and i am using Vb.net Forms ) the error in SQL statment and the image link down shows the error my code is
Try
Dim MyStringDate1 As Date = CDate(DateTimePicker1.Value.Date)
Dim MyStringDate2 As Date = CDate(DateTimePicker2.Value.Date)
con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source =" & Application.StartupPath & "\LIBRARY.mdb"
con.Open()
sql = "select CATEGORY , COUNT(CATEGORY)as CatStac from tblRentals where dateIssued between #" & MyStringDate1 & "# AND #" & MyStringDate2 & "# from tblRentals GROUP BY CATEGORY"
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "tblRentals")
con.Close()
Catch ex As Exception
MsgBox(ex.Message)
MsgBox(" SQL OR CONNECTION ERROR ")
End Try
Try
Dim T As Title = Chart1.Titles.Add("CATEGORY STACS FOR LIBRARY")
'~~> Formatting the Title
With T
.ForeColor = Color.Black '~~> Changing the Fore Color of the Title
.BackColor = Color.Coral '~~> Changing the Back Color of the Title
'~~> Setting Font, Font Size and Bold/Italicizing
.Font = New System.Drawing.Font("Times New Roman", 11.0F, System.Drawing.FontStyle.Bold)
.Font = New System.Drawing.Font("Times New Roman", 11.0F, System.Drawing.FontStyle.Underline)
.BorderColor = Color.Black '~~> Changing the Border Color of the Title
.BorderDashStyle = ChartDashStyle.DashDotDot '~~> Changing the Border Dash Style of the Title
End With
Chart1.DataSource = ds.Tables("tblRentals")
Dim Series1 As Series = Chart1.Series("Series1")
Series1.Name = "CATEGORY STACS"
Chart1.Series(Series1.Name).ChartType = SeriesChartType.Pie
' Chart1.Series(Series1.Name).LabelFormat = "0"
Chart1.Series(Series1.Name).IsValueShownAsLabel = True
Chart1.Series(Series1.Name).XValueMember = "CATEGORY"
Chart1.Series(Series1.Name).YValueMembers = "CatStac"
Dim LG As Legend = Chart1.Legends(0)
'~~> Changing the Back Color of the Legend
LG.BackColor = Color.Wheat
'~~> Changing the Fore Color of the Legend
LG.ForeColor = Color.DarkSlateBlue
'~~> Setting Font, Font Size and Bold
LG.Font = New System.Drawing.Font("Times New Roman", 11.0F, System.Drawing.FontStyle.Bold)
'~~> Assigning a title for the legend
LG.Title = "Legend"
Chart1.Size = New System.Drawing.Size(500, 500)
Catch ex As Exception
MsgBox(ex.Message)
MsgBox("CHART ERROR ")
End Try