Sub CalculateInterest()
Dim month, b_month, year As String
Dim rate, b_rate, interest, b_interest, savingdep, plus As Double
Dim i As Integer
Dim id As Integer
'=========================================================================================='
strsql = " SELECT * FROM EMPLOYEEDT INNER JOIN EMPLOYEE ON EMPLOYEE.MEMP = EMPLOYEEDT.MEMP WHERE EMPLOYEE.STATUS = 'YES'"
dtAdapter = New SqlDataAdapter(strsql, myConn)
dtAdapter.Fill(dt3)
For i = 0 To dt3.Rows.Count - 1
id = dt3.Rows(i)("MEMP")
savingdep = dt3.Rows(i)("SAVINGDEP")
'================================================================================
b_month = SplitB_Month(dateInput.Text)
Select Case b_month
Case "มกราคม"
b_rate = 0.666667
Case "กุมภาพันธ์"
b_rate = 1.333333
Case "มีนาคม"
b_rate = 2.0
Case "เมษายน"
b_rate = 2.666667
Case "พฤษภาคม"
b_rate = 3.333333
Case "มิถุนายน"
b_rate = 4.0
Case "กรกฎาคม"
b_rate = 4.666667
Case "สิงหาคม"
b_rate = 5.333333
Case "กันยายน"
b_rate = 6.0
Case "ตุลาคม"
b_rate = 6.666667
Case "พฤศจิกายน"
b_rate = 7.333333
Case "ธันวาคม"
b_rate = 8.0
End Select
b_interest = savingdep * b_rate / 100
'========================================================================================='
month = SplitMonth(dateInput.Text)
Select Case month
Case "มกราคม"
rate = 0.666667
Case "กุมภาพันธ์"
rate = 1.333333
Case "มีนาคม"
rate = 2.0
Case "เมษายน"
rate = 2.666667
Case "พฤษภาคม"
rate = 3.333333
Case "มิถุนายน"
rate = 4.0
Case "กรกฎาคม"
rate = 4.666667
Case "สิงหาคม"
rate = 5.333333
Case "กันยายน"
rate = 6.0
Case "ตุลาคม"
rate = 6.666667
Case "พฤศจิกายน"
rate = 7.333333
Case "ธันวาคม"
rate = 8.0
End Select
interest = savingdep * rate / 100
'=============================================================================================='
plus = interest - b_interest
plus = Math.Round(plus, 2)
'==============================================================================================='
strsql = " UPDATE EMPLOYEEDT SET AINTEREST = AINTEREST + '" + plus + "' WHERE MEMP = '" + id + "' " 'ERROR ที่บรรทัดนี้ค่ะ
cmd = New SqlCommand(strsql, myConn)
cmd.ExecuteNonQuery()
Next
End Sub
รบกวนพี่ๆ ช่วยดูให้ทีค่ะ ติด ERROR Conversion from string to type 'Double' is not valid ขอบคุณมากๆค่ะ
Tag : .NET, Web (ASP.NET), VB.NET, VS 2010 (.NET 4.x)