Protected Sub updatedata()
Dim strSQL As String
strSQL = "UPDATE company_alert, company_financial"
strSQL = strSQL & " company_alert.alert_value = (company_financial.receivable * 360 / company_financial.revenue)"
strSQL = strSQL & "WHERE company_alert.alert_id='DSO' AND company_alert.stock_code = company_financial.stock_code AND company_alert.year_id = company_financial.year_id AND company_alert.period_id = company_financial.period_id"
cmd = New MySqlCommand(strSQL, conn)
cmd.ExecuteNonQuery()
End Sub
Protected Sub insertdata()
Dim strSQL As String
strSQL = "INSERT INTO company_alert (stock_code, year_id, period_id,alert_id, alert_value) "
strSQL = strSQL & "SELECT a.stock_code, a.year_id, a.period_id,alert_id,(a.receivable*360/a.revenue) AS dso1 "
strSQL = strSQL & "FROM ref_alert_parameter, company_financial a "
strSQL = strSQL & "WHERE alert_id='DSO' AND a.year_id BETWEEN '" & byear1 & "' AND '" & byear2 & "' AND a.period_id = '5'"
cmd = New MySqlCommand(strSQL, conn)
cmd.ExecuteNonQuery()
cmd.CommandTimeout = 0
End Sub
I insert data 1st next im gonna update the data..is it true or update then insert?