The datasource doesn't contain a datamember with the "duration" name - vb.net

By using Dev express chart control am populating some of charts which are based on today,yesterday,week ,months and year based query.But the Problem is that am getting this error .
The datasource doesn't contain a datamember with the "duration" name.
where getDataset is global function which am using from last 6 months which is perfectly alright.plz help. help is appreciated
Here is my complete method
Protected Sub populateLoginHistoryChart(ByVal ddlSelectedValue As String)
Dim sqlQuery As String = Nothing
sqlQuery = "SELECT LT.LogOnTime AS duration , COUNT(*) AS posts "
sqlQuery += " FROM ( "
sqlQuery += "SELECT CASE"
sqlQuery += " When DATEPART(hh,[LogOnTime]) >= 0 AND DATEPART(hh,[LogOnTime]) <= 4 AND DATEPART(mm,[LogOnTime]) <= 59 then '00:00-04:00'"
sqlQuery += " When DATEPART(hh,[LogOnTime]) >= 4 AND DATEPART(hh,[LogOnTime]) <= 8 AND DATEPART(mm,[LogOnTime]) <= 59 then '04:00-08:00' "
sqlQuery += " When DATEPART(hh,[LogOnTime]) >= 8 AND DATEPART(hh,[LogOnTime]) <= 12 AND DATEPART(mm,[LogOnTime]) <= 59 then '08:00-12:00' "
sqlQuery += " When DATEPART(hh,[LogOnTime]) >= 12 AND DATEPART(hh,[LogOnTime]) <= 16 AND DATEPART(mm,[LogOnTime]) <= 59 then '12:00-16:00' "
sqlQuery += " When DATEPART(hh,[LogOnTime]) >= 16 AND DATEPART(hh,[LogOnTime]) <= 20 AND DATEPART(mm,[LogOnTime]) <= 59 then '16:00-20:00' "
sqlQuery += " When DATEPART(hh,[LogOnTime]) >= 20 AND DATEPART(hh,[LogOnTime]) <= 23 AND DATEPART(mm,[LogOnTime]) <= 59 then '20:00-23:00' "
sqlQuery += " End as LogOnTime "
sqlQuery += " FROM StudentLoginHistory"
If ddlSelectedValue = "Today" Then
sqlQuery += " WHERE DATEADD(dd, 0, DATEDIFF(dd, 0, LogOnTime)) = DATEADD(dd, 0, DATEDIFF(dd, 0, GETDATE()))"
sqlQuery += " )LT "
ElseIf ddlSelectedValue = "Yesterday" Then
sqlQuery += " WHERE DATEADD(dd, 0, DATEDIFF(dd, 0, LogOnTime)) = DATEADD(dd, 0, DATEDIFF(dd, 0, GETDATE()))-1 "
sqlQuery += " )LT "
End If
sqlQuery += " GROUP BY LT.LogOnTime"
sqlQuery += " ORDER BY duration"
If ddlSelectedValue = "Week" Then
sqlQuery = "SELECT CONVERT(varchar(25),LogOnTime,107) AS duration, count(*) AS posts"
sqlQuery += " FROM StudentLoginHistory WHERE "
sqlQuery += " DateDiff(Week,LogOnTime,GetDate())=1"
sqlQuery += " GROUP BY CONVERT(varchar(25),LogOnTime,107)"
sqlQuery += " ORDER BY duration"
ElseIf ddlSelectedValue = "Month" Then
sqlQuery = "SELECT LT.LogOnTime AS duration, COUNT(*) AS posts"
sqlQuery += " FROM (SELECT CASE "
sqlQuery += " When DATEPART(dd,[LogOnTime]) >= 1 AND DATEPART(dd,[LogOnTime]) <= 7 then '2013-05-01 to 2013-05-07'"
sqlQuery += " When DATEPART(dd,[LogOnTime]) >= 8 AND DATEPART(dd,[LogOnTime]) <= 14 then '2013-05-08 to 2013-05-14'"
sqlQuery += " When DATEPART(dd,[LogOnTime]) >= 15 AND DATEPART(dd,[LogOnTime]) <= 21 then '2013-05-15 to 2013-05-21' "
sqlQuery += " When DATEPART(dd,[LogOnTime]) >= 22 AND DATEPART(dd,[LogOnTime]) <= 28 then '2013-05-22 to 2013-05-28'"
sqlQuery += " End as LogOnTime "
sqlQuery += " FROM StudentLoginHistory"
sqlQuery += " WHERE(DatePart(mm, LogOnTime) = DatePart(mm, DateAdd(mm, -1, getdate())) AND DatePart(yyyy, LogOnTime) = DatePart(yyyy, DateAdd(mm, -1, getdate())))"
sqlQuery += " )LT "
sqlQuery += " GROUP BY LT.LogOnTime"
ElseIf ddlSelectedValue = "Year" Then
sqlQuery = "SELECT CONVERT(varchar(4),LogOnTime , 100) + CONVERT(varchar(4), LogOnTime, 120) AS duration,COUNT(*) AS posts"
sqlQuery += " FROM StudentLoginHistory WHERE "
sqlQuery += " year(LogOnTime) = year(DATEADD(year,-1,getdate())) "
sqlQuery += "GROUP BY CONVERT(varchar(4),LogOnTime , 100) + CONVERT(varchar(4), LogOnTime, 120) "
sqlQuery += "ORDER BY month(CONVERT(varchar(4),LogOnTime , 100) + CONVERT(varchar(4), LogOnTime, 120))"
End If
Dim ds As DataSet = objglb.getDataset(sqlQuery, "tbl")
Dim Title As New DevExpress.XtraCharts.ChartTitle()
Dim Diagram As XYDiagram = CType(LoginHistoryChart.Diagram, XYDiagram)
LoginHistoryChart.Titles.Clear()
Dim Series As New Series("Series", ViewType.Bar)
LoginHistoryChart.Series.Add(Series)
Series.DataSource = ds
Series.ArgumentDataMember = "duration"
Series.ValueScaleType = ScaleType.Numerical
Series.ValueDataMembers.AddRange(New String() {"posts"})
If ddlSelectedValue = "Today" Then
Title.Text = "Login History By Today"
ElseIf ddlSelectedValue = "Yesterday" Then
Title.Text = "Login History By Yesterday"
ElseIf ddlSelectedValue = "Week" Then
Title.Text = "Login History By Last Week"
ElseIf ddlSelectedValue = "Month" Then
Title.Text = "Login History By Last Month"
ElseIf ddlSelectedValue = "Year" Then
Title.Text = "Login History By Last Year"
End If
'the appearance of the X-axis title.
Diagram.AxisX.Title.Visible = True
Diagram.AxisX.Title.Alignment = StringAlignment.Center
If ddlSelectedValue = "Today" OrElse ddlSelectedValue = "Yesterday" Then
Diagram.AxisX.Title.Text = "Hours"
ElseIf ddlSelectedValue = "Week" Then
Diagram.AxisX.Title.Text = "Days"
ElseIf ddlSelectedValue = "Month" Then
Diagram.AxisX.Title.Text = "Weeks"
ElseIf ddlSelectedValue = "Year" Then
Diagram.AxisX.Title.Text = "Months"
End If
Diagram.AxisX.Title.TextColor = Color.Black
Diagram.AxisX.Title.Font = New Font("georgia", 12, FontStyle.Regular)
Diagram.AxisX.Range.Auto = False
'the appearance of the Y-axis title.
Diagram.AxisY.Title.Visible = True
Diagram.AxisY.Title.Alignment = StringAlignment.Center
Diagram.AxisY.Title.Text = "Logins Counts"
Diagram.AxisY.Title.TextColor = Color.Black
Diagram.AxisY.Title.Antialiasing = True
Diagram.AxisY.Title.Font = New Font("georgia", 10)
CType(Series.View, SideBySideBarSeriesView).ColorEach = True
LoginHistoryChart.Width = 900
LoginHistoryChart.Legend.Visible = False
LoginHistoryChart.Titles.Add(Title)
Title.Font = New Font("georgia ", 14)
End Sub

I don't see that you are setting the name of the table to bind to anywhere. I would change
Series.DataSource = ds
to
Series.DataSource = ds.Tables["tbl"]

Related

How to speed up pie charts creation in VB Web?

I have a web page that can create multiple pie charts based on an SQL query that executes when the page is loading. However I have noticed that the page loading takes too long (around 30 seconds). I checked the SQL formula and can confirm that it is working fine (results given almost instantly).
There are 40 different pie charts the page needs to create, and the page also have the option to generate a single pie chart and that works fast enough.
So I can deduce that it's the pie chart generation that is slow when it needs to create 40 of them. Is there a way to help speed up the pie chart creation process?
Here is my code for reference.
Sub draw_chart1() 'All Machines
Dim check1, check2, fi, cnt
Dim sql
Dim myConnectionString As String = "Provider=SQLOLEDB;" & SQLDB_pp.ConnectionString
fi = 0
cnt = 0
PlaceHolder1.Dispose()
PlaceHolder2.Dispose()
'Get all model
Dim query1 As String = String.Format("SELECT DISTINCT A.MacID FROM dbo.tblMachine A LEFT JOIN dbo.tblDataHdr b on a.MacID = b.MacID where DayID between '" & TextBox1.Text & "' AND '" & TextBox3.Text & "' ORDER BY A.MACID")
Dim dt1 As DataTable = GetData(query1)
For Q As Integer = 0 To dt1.Rows.Count - 1
'For Q As Integer = 0 To 1
check1 = dt1.Rows(Q)(0).ToString()
'This is the slow query
Dim query As String = String.Format("SELECT Z.MacID, Z.EventName, ISNULL(DIFF,0) AS DIFF FROM (select distinct MacID, EventName from dbo.tblMachine a join (SELECT DISTINCT EVENTNAME FROM dbo.tblEvtDur where EventName <> 'ON' ) b on b.EventName <> '' and MacID in ('" & check1 & "') ) Z LEFT JOIN (SELECT A.MacID, A.EventName, SUM(DATEDIFF(SECOND, A.STARTdt, A.eNDdt)) as diff,round(SUM(DATEDIFF(SECOND, A.STARTdt, A.eNDdt)) / cast(aVG(Tdiff) as decimal(30,8)),4) * 100 AS PER FROM dbo.tblEvtDur A LEFT JOIN ( SELECT MacID, SUM(DATEDIFF(SECOND, STARTdt, eNDdt)) as Tdiff FROM dbo.tblEvtDur WHERE DayID between '" & TextBox1.Text & "' and '" & TextBox3.Text & "' GROUP BY MacID ) B ON A.MacID = B.MacID WHERE DayID between '" & TextBox1.Text & "' and '" & TextBox3.Text & "' AND A.MacID in ('" & check1 & "') group by A.MacID, A.EventName) a ON A.EVENTNAME = Z.EVENTNAME and Z.MacID = a.MacID order by Z.MacID, Z.EventName")
Dim mychart As Chart = New Chart
' Dim myplace As PlaceHolder = New PlaceHolder
Dim ChartArea1 As ChartArea = New ChartArea
Dim Legend1 As Legend = New Legend
Dim dt As DataTable = GetData(query)
Dim x As String() = New String(dt.Rows.Count - 1) {}
Dim y As Integer() = New Integer(dt.Rows.Count - 1) {}
For i As Integer = 0 To dt.Rows.Count - 1
x(i) = dt.Rows(i)(1).ToString()
' y(i) = dt.Rows(i)(2).ToString()
y(i) = Convert.ToInt32(dt.Rows(i)(2))
Next
'Dim myConnection As New OleDbConnection(myConnectionString)
'Dim myCommand As New OleDbCommand(sql, myConnection)
'mychart.Width = Unit.Pixel(Session("sw") - 100)
'mychart.Height = Unit.Pixel((Session("sh") / 2) - 88)
mychart.Width = 600
mychart.Height = 400
mychart.ChartAreas.Clear()
mychart.ChartAreas.Add("ChartArea1")
mychart.Series.Clear()
mychart.Series.Add(0)
mychart.Series(0).Points.DataBindXY(x, y)
mychart.Titles.Clear()
mychart.Titles.Add("[" & Q + 1 & "] " & check1.ToString.ToUpper)
mychart.Titles(0).Font = New System.Drawing.Font("Tahoma", 12, System.Drawing.FontStyle.Bold)
mychart.Titles(0).BackColor = Color.PaleTurquoise
mychart.Titles(0).ForeColor = Color.Black
mychart.Series(0).ChartType = SeriesChartType.Pie
' mychart.Series(0).Points.DataBindXY(x, y)
mychart.Series(0).LegendText = "#VALX"
mychart.Series(0)("BarLabelStyle") = "Center"
mychart.Series(0)("pointWidth") = "1"
mychart.Series(0).BorderDashStyle = ChartDashStyle.Solid
mychart.Series(0).BorderWidth = 2
mychart.Series(0).Label = "#PERCENT"
mychart.Series(0).ShadowColor = Color.Gray
mychart.Series(0).ShadowOffset = 10
mychart.Series(0).LabelBackColor = Drawing.Color.Cornsilk
mychart.Series(0).Font = New Font("Tahoma", 9, FontStyle.Bold)
'Chart1.Series(0).LabelToolTip = "#LABEL Percent: #PERCENT"
mychart.Series(0).LegendToolTip = "#VALX - #PERCENT"
mychart.Series(0).ToolTip = "#VALX - #PERCENT"
mychart.ChartAreas("ChartArea1").Area3DStyle.Enable3D = True
mychart.Series(0).CustomProperties = "DrawingStyle=LightToDark"
'new
Chart1.Series(0).CustomProperties = "PieLabelStyle=Outside"
mychart.ChartAreas("ChartArea1").BorderDashStyle = BorderStyle.Solid
mychart.Palette = ChartColorPalette.None
mychart.Series(0).BorderDashStyle = ChartDashStyle.Solid
mychart.Series(0).BorderWidth = 2
mychart.Series(0).BorderColor = Color.Black
mychart.PaletteCustomColors = {Drawing.Color.Black, Drawing.Color.LightGray, Drawing.Color.Blue, Drawing.Color.Yellow, Drawing.Color.Red, Drawing.Color.Orange, Drawing.Color.Green}
mychart.Legends.Clear()
mychart.Legends.Add(0)
'Chart1.Legends(0).Enabled = True
''Chart1.Legends(0).BackColor = Drawing.Color.LightGreenplace
mychart.Legends(0).Font = New Font("Tahoma", 10, FontStyle.Bold)
mychart.Legends(0).Docking = System.Web.UI.DataVisualization.Charting.Docking.Bottom
'Chart1.Legends(0).Alignment = Drawing.StringAlignment.Center
'Chart1.Legends(0).BackColor = System.Drawing.Color.Transparent
mychart.DataBind()
'myplace.Visible = True
If (Q + 1) Mod 2 <> 0 Then
PlaceHolder1.Controls.Add(mychart)
' Dim spacer As LiteralControl = New LiteralControl("<p />")
' PlaceHolder1.Controls.Add(spacer)
End If
'Exit For
If (Q + 1) Mod 2 = 0 Then
PlaceHolder2.Controls.Add(mychart)
'Dim spacer As LiteralControl = New LiteralControl("<p />")
' PlaceHolder2.Controls.Add(spacer)
End If
Next
End Sub

SQL Syntax error, expression of non-boolean type

This code is supposed to create a graph of revenue from money made through sales tickets at an event.
The code only executes up to da.Fill(ds) when it returns the error, which can be seen at the end of the code.
Does anybody know why
Private Sub frmRevenue_Load(sender As Object, e As EventArgs) Handles Me.Load
frmMDI.addFormToCMS()
Dim dt As DataTable
dt = New DataTable
dt.Columns.Add("Fee")
Dim sales As Integer = 0
Dim gridtable As New DataTable
gridtable.Columns.Add("Month")
gridtable.Columns.Add("Total")
gridtable.Columns.Add("#")
For i = 1 To 12
sql = "SELECT Fee FROM tblTickets WHERE MONTH(DatePurchased) = " & i & " AND (YEAR(DatePurchased) = " & Today.Year & " OR " & Year(Today.AddYears(1)) & ") AND (Status = 'SOLD' OR RESERVED" _
& " = 'AWAITING CONFIRMATION' OR Status = 'AVAILABLE' OR Status = 'AWAITING PAYMENT');"
da = New OleDb.OleDbDataAdapter(sql, con)
ds = New DataSet
da.Fill(ds)
Dim dr As DataRow
For Each dr In ds.Tables(0).Rows
monthly(i) = monthly(i) + 1
contracts = sales + 1
total(i) = total(i) + dr.Item("Fee")
yearlytotal = yearlytotal + dr.Item("Fee")
Next
Next
For i = 1 To 12
Dim month As String
Select Case i
Case 1
month = "Jan"
Case 2
month = "Feb"
Case 3
month = "Mar"
Case 4
month = "Apr"
Case 5
month = "May"
Case 6
month = "Jun"
Case 7
month = "Jul"
Case 8
month = "Aug"
Case 9
month = "Sep"
Case 10
month = "Oct"
Case 11
month = "Nov"
Case 12
month = "Dec"
Case Else
month = "ERR"
End Select
gridtable.Rows.Add(month, FormatCurrency(total(i)), monthly(i))
Next
ugTickets.DataSource = gridtable
ugTickets.DisplayLayout.Bands(0).Columns("Month").Width = 35
ugTickets.DisplayLayout.Bands(0).Columns("#").Width = 20
ugTickets.DisplayLayout.Override.AllowUpdate = DefaultableBoolean.False
txtAnnual.ReadOnly = True
txtAnnual.BackColor = Color.White
txtAnnualContracts.ReadOnly = True
txtAnnualContracts.BackColor = Color.White
chRevenue.Titles("chTitle").Text = "Predicted revenue for " & Today.Year & " - " & Year(Today.AddYears(1))
txtAnnual.Text = FormatCurrency(yearlytotal, 2)
txtAnnualContracts.Text = contracts
chRevenue.Series("Series1").Name = "Revenue"
For i = 1 To 12
chRevenue.Series("Revenue").Points.AddY(total(i))
Next
Try
chRevenue.BackColor = Color.Transparent
chRevenue.Legends("Revenue").BackColor = Color.Transparent
chRevenue.Series("Revenue").ChartArea = "ChartArea1"
chRevenue.Series("Revenue").Color = Color.SkyBlue
chRevenue.Series("Revenue").ToolTip = FormatCurrency("#VALY", 2)
Catch
End Try
End Sub
An expression of non-boolean type specified in a context where a condition is expected, near ')'.
The problem is with this bit of the SQL:
(YEAR(DatePurchased) = " & Today.Year & " OR " & Year(Today.AddYears(1)) & ")
It should probably be
(YEAR(DatePurchased) = " & Today.Year & " OR YEAR(DatePurchased) = " & Year(Today.AddYears(1)) & ")
The OR in SQL (and in most other languages) needs to have two independently valid conditions on each side. The left hand side currently looks like this:
YEAR(DatePurchased) = 2016
...which is fine. But the right looks like this:
2017
...which isn't a valid boolean.
When you get an error like this on the da.Fill() line (ie. the line that's actually running the SQL in the database), the easiest way to debug it is to print out the value of the "sql" variable.
Often, you can just look at the SQL it's generated and the problem will be obvious. Other times you have to copy it and run it directly against your database to see what the problem is.
Might be your SQL, try:
"SELECT Fee FROM tblTickets WHERE MONTH(DatePurchased) = '" & i &
"' AND (YEAR(DatePurchased) = '" & Today.Year &
"' OR '" & Year(Today.AddYears(1)) & "') " &
"AND (Status = 'SOLD' OR RESERVED = 'AWAITING CONFIRMATION' " &
"OR Status = 'AVAILABLE' " &
"OR Status = 'AWAITING PAYMENT');"

age calculation in vb.net coding

net coding and i am really stuck in this basic age calculation. I have created a form field and in a groupbox it should display the age of a person. The biggest problem i am facing with the code is factoring in the month. I have tried all types such as using DateInterval.Month but still no luck. Here MyEntPatient.DOB is the DOB of patient
Dim Years As Integer
Dim BDAY As New DateTime(Now.Year)
BDAY = MyEntPatient.DOB
If (BDAY > Now) Then
Years = DateDiff(DateInterval.Year, MyEntPatient.DOB, Now) - 1
Else
Years = DateDiff(DateInterval.Year, MyEntPatient.DOB, Now)
End If
Me.gpxPatientDetails.Text = " Age:" + Years.ToString()
I think you want to have the difference of the date, I think this example help you:
Dim birthday As New DateTime(12, 12, 2012)
Dim difference As DateTime = DateTime.Now - birthday
Dim years As Integer = difference.Years
If you have problem with bigger/smaller age, because someone doesn't have a birthday this year (born in December for example), you can try this:
Dim bday As New DateTime(2010, 1, 25)
Dim months As Integer = DateDiff(DateInterval.Month, bday, Now)
Dim years As Integer = months / 12
Function AgeCalculator(ByVal FromDate As String, Optional flgyearOnly As Boolean = False) As String '23/11/2017
If Not IsDate(FromDate) Then Return ""
Dim tmpYear As String = "", tmpMonth As String = "", tmpdiff As Integer = 0
Dim tmpAge As String = ""
tmpdiff = DateDiff(DateInterval.Day, CDate(Format2DateMMM(FromDate)), Now)
If tmpdiff <= 0 Then Return ""
If tmpdiff > 0 And tmpdiff <= 29 Then
Return tmpdiff & " Days"
End If
If tmpdiff = 30 Then
Return " 1 Month"
End If
tmpYear = tmpdiff / 365
If InStr(tmpYear, ".") > 0 Then
tmpYear = Microsoft.VisualBasic.Left(tmpYear, InStr(tmpYear, ".") - 1)
End If
If Val(tmpYear) = 0 Then tmpYear = ""
If Val(tmpYear) > 0 Then
tmpAge = tmpYear & " years"
If flgyearOnly Then Return tmpAge
End If
tmpdiff = (tmpdiff - (Val(tmpYear) * 365))
tmpMonth = tmpdiff / 30
If InStr(tmpMonth, ".") > 0 Then
tmpMonth = Microsoft.VisualBasic.Left(tmpMonth, InStr(tmpMonth, ".") - 1)
End If
If Val(tmpMonth) = 0 Then tmpMonth = ""
If tmpMonth > 0 Then
tmpAge &= " " & tmpMonth & " Months"
End If
tmpdiff = (tmpdiff - (Val(tmpMonth) * 30))
If Val(tmpdiff) > 0 Then
tmpAge &= " " & tmpdiff & " Days"
End If
Return tmpAge: End Function
A bit old posting, but the question is not!
Typically the 'age' is the whole years completed:
Dim DOB As Date = DateValue("1970-10-28")
Dim Tday As Date = DateValue("2022-02-21")
Console.WriteLine(
Int((CInt(Tday.ToString("yyyyMMdd")) - CInt(DOB.ToString("yyyyMMdd"))) / 10000)
)

commandtext property has not been initialized vb.net

I am new to vb.net and tried to execute the code its working fine but when I am scheduling the code in another server in network by running the exe file only, then I am getting the error as:
"commandtext property has not been initialized"
Sub send_SMS()
Console.WriteLine("Begining of the send_SMS() ")
Dim dt As New DataTable
Dim st1, sql As String
Dim fetcheduser, fetchedpno As String
Dim J As Integer
J = Now.Hour
Console.WriteLine("J Now.Hour =: " + J.ToString)
'A shift
If J >= 14 And J < 22 Then
sql = " SELECT * FROM YKPI_VALUE "
sql = sql & " WHERE KPV_USER_ID='QEXP' "
sql = sql & " AND KPV_TYP_ID='A' "
sql = sql & " AND KPV_FROM_DATE=TO_CHAR(SYSDATE,'YYYYMMDD') "
Console.WriteLine("J = 14 ")
st.Text = "A"
End If
'B Shift
If J >= 22 And J < 6 Then
sql = " SELECT * FROM YKPI_VALUE "
sql = sql & " WHERE KPV_USER_ID='QEXP' "
sql = sql & " AND KPV_TYP_ID='B' "
sql = sql & " AND KPV_FROM_DATE=TO_CHAR(SYSDATE,'YYYYMMDD') "
Console.WriteLine("J = 22 ")
st.Text = "B"
End If
'C Shift
If J >= 6 And J < 14 Then
sql = " SELECT * FROM YKPI_VALUE "
sql = sql & " WHERE KPV_USER_ID='QEXP' "
sql = sql & " AND KPV_TYP_ID='C' "
sql = sql & " AND KPV_FROM_DATE=TO_CHAR(SYSDATE-1,'YYYYMMDD') "
Console.WriteLine("J = 6 ")
st.Text = "C"
DAT = DAT.AddDays(-1)
End If
Dim DA As New OracleDataAdapter(sql, oraconn)
DA.Fill(dt)
Console.WriteLine("Before dt.Rows count ")
Dim MaxRows, MaxColums, inc As Integer
MaxRows = dt.Rows.Count
MaxColums = dt.Columns.Count
Dim multiarray(,) As String = New String(MaxRows, MaxColums) {}
Console.WriteLine("Value of MaxRows = " + MaxRows.ToString)
Console.WriteLine("Value of MaxColums = " + MaxColums.ToString)
If (inc <> MaxRows) Then
'inc = inc + 1
Console.WriteLine("Inside dt.Rows and Before for loop ")
For inc = 0 To MaxRows - 1
'For col = 0 To MaxColums
dt.Rows(inc).Item(10) = dt.Rows(inc).Item(10).ToString.Replace("Q", "")
multiarray(inc, 1) = dt.Rows(inc).Item(2).ToString()
multiarray(inc, 2) = dt.Rows(inc).Item(4).ToString()
multiarray(inc, 3) = dt.Rows(inc).Item(10).ToString()
Next
End If
Dim queryusr As String
queryusr = ""
Dim sql_CMD_TD As New OracleCommand(sql, oraconn)
If Not oraconn.State = ConnectionState.Open Then
oraconn.Open()
End If
Dim doNotSendSMS = False
Dim sqldr As OracleDataReader = sql_CMD_TD.ExecuteReader()
If sqldr.HasRows Then
oraconn.Close()
queryusr = " SELECT TSU_USER,TSU_USERNAME FROM T_SDM_USERS "
queryusr = queryusr & "WHERE TSU_SCREENID='QESMS'AND TSU_VALIDITY='Y' "
dt = New DataTable
DA = New OracleDataAdapter(queryusr, oraconn)
DA.Fill(dt)
If Not doNotSendSMS Then
Dim ora_CMD_SMS As New OracleCommand(queryusr, oraconn)
If oraconn.State = ConnectionState.Closed Then
oraconn.Open()
End If
st1 = st.Text
Dim ORA_DR As OracleDataReader = ora_CMD_SMS.ExecuteReader()
If ORA_DR.HasRows Then
While ORA_DR.Read()
fetcheduser = ORA_DR("TSU_USERNAME")
fetchedpno = ORA_DR("TSU_USER")
Console.WriteLine("Before insertIntoSMS function call ")
Console.WriteLine(" Value of st1 :" + st1.ToString)
insertIntoSMS_hbf(fetcheduser, fetchedpno, st1, multiarray, MaxRows, MaxColums)
Console.WriteLine("Outside of insertIntoSMS function call ")
End While
ORA_DR.Close()
End If
If oraconn.State = ConnectionState.Open Then
oraconn.Close()
End If
End If
End If
End Sub

VB code not calculating

For some reason when I run this it only ever calculates to 0
Where am I going wrong? :(
The user has 3 input boxes to place values. From there those values should be calculating. It only ever equals a value of 0. I get no errors
Option Strict On
Public Class Form1
Private Sub btnCal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCal.Click
Dim dblPacA, dblPacB, dblPacC, dblAnswerA, dblAnswerB, dblAnswerC, dblGrandTotal As Double
Dim dblAnswerA1, dblAnswerB1, dblAnswerC1 As Double
'Packages Retail
Dim dblPACA_FACTOR As Double = 99
Dim dblPACB_FACTOR As Double = 199
Dim dblPACC_FACTOR As Double = 299
'Rate of each range
Dim dblTENNINE_FACTOR As Double = 0.8
Dim dblTWONINE_FACTOR As Double = 0.7
Dim dblFIVENINE_FACTOR As Double = 0.6
Dim dblONETEN_FACTOR As Double = 0.5
Try
'important calculate
dblAnswerA1 = dblPacA * dblPACA_FACTOR
dblAnswerB1 = dblPacB * dblPACB_FACTOR
dblAnswerC1 = dblPacC * dblPACC_FACTOR
dblPacA = CDbl(txtPacA.Text)
dblPacB = CDbl(txtPacB.Text)
dblPacC = CDbl(txtPacC.Text)
dblGrandTotal = dblAnswerA + dblAnswerB + dblAnswerC
lblGrandTotal.Text = "Gran Total:" & (dblGrandTotal.ToString("c"))
'lblAnswer.Text = dblAnswer.ToString
'lblAnswer.Text = "PackageA:" & dblAnswerA _
' & "PackageB:" & dblAnswerB & "PackageC:" _
'& dblAnswerC & "GrandTotal:" & dblGrandTotal
Catch
End Try
If dblPacA >= 0 Then
If dblPacA < 10 Then
dblAnswerA = dblAnswerA1
lblAnswerA.Text = "PackageA:" & dblAnswerA.ToString("c")
ElseIf dblPacA >= 10 And dblPacA < 20 Then
dblAnswerA = dblAnswerA1 * dblTENNINE_FACTOR
lblAnswerA.Text = "PackageA:" & (dblAnswerA.ToString("c"))
ElseIf dblPacA >= 20 And dblPacA < 50 Then
dblAnswerA = dblAnswerA1 * dblTWONINE_FACTOR
lblAnswerA.Text = "PackageA:" & dblAnswerA.ToString("c")
ElseIf dblPacA >= 50 And dblPacA < 100 Then
dblAnswerA = dblAnswerA1 * dblFIVENINE_FACTOR
lblAnswerA.Text = "PackageA:" & dblAnswerA.ToString("c")
ElseIf dblAnswerA >= 100 Then
dblAnswerA = dblAnswerA1 * dblONETEN_FACTOR
lblAnswerA.Text = "PackageA:" & dblAnswerA.ToString("c")
End If
Else
MessageBox.Show("txtPacA must be greater than or equal to 0", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning)
End If
If dblPacB >= 0 Then
If dblPacB >= 10 And dblPacB <= 19 Then
dblAnswerB = dblAnswerB1 * dblTENNINE_FACTOR
lblAnswerB.Text = "PackageB:" & dblAnswerB.ToString("c")
ElseIf dblPacB >= 20 And dblPacB <= 49 Then
dblAnswerB = dblAnswerB1 * dblTWONINE_FACTOR
lblAnswerB.Text = "PackageB:" & dblAnswerB.ToString("c")
ElseIf dblPacB >= 50 And dblPacB <= 99 Then
dblAnswerB = dblAnswerB1 * dblFIVENINE_FACTOR
lblAnswerB.Text = "PackageB:" & dblAnswerB.ToString("c")
Else
dblAnswerB = dblAnswerB * dblONETEN_FACTOR
lblAnswerB.Text = "PackageB:" & dblAnswerB.ToString("c")
End If
Else
MessageBox.Show("txtPacB must be greater than or equal to 0", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning)
End If
If dblPacC >= 0 Then
If dblPacC >= 10 And dblPacC <= 19 Then
dblAnswerC = dblAnswerC1 * dblTENNINE_FACTOR
lblAnswerC.Text = "PackageC:" & dblAnswerC.ToString("c")
ElseIf dblPacC >= 20 And dblPacA <= 49 Then
dblAnswerC = dblAnswerC1 * dblTWONINE_FACTOR
lblAnswerC.Text = "PackageC:" & dblAnswerC.ToString("c")
ElseIf dblPacC >= 50 And dblPacC <= 99 Then
dblAnswerC = dblAnswerC1 * dblFIVENINE_FACTOR
lblAnswerC.Text = "PackageC:" & dblAnswerC.ToString("c")
Else
dblAnswerC = dblAnswerC1 * dblONETEN_FACTOR
lblAnswerC.Text = "PackageC:" & dblAnswerC.ToString("c")
End If
Else
MessageBox.Show("txtPacC must be greater than or equal to 0", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning)
End If
End Sub
End Class
dblAnswerA1 = dblPacA * dblPACA_FACTOR
where is dblPacA 's value set? its not. its 0