Hello, How can input number to database where my field in database data type money..
This is my code:
Private Sub SaveData()
Try
If adcLEDGER.State = ADODB.ObjectStateEnum.adStateOpen Then adcLEDGER.Close()
adcLEDGER.ConnectionString = strCONNECT
adcLEDGER.Open()
Catch ex As Exception
MsgBox(ex.Message)
End Try
Try
Dim vANSWER
vANSWER = vbYes
modPY.LookUpST(adcLEDGER, "SELECT * FROM MS_UMR WHERE TAHUN = '" & Trim(txtTahun.Text) & "'", strTahun) ' And (CStr(Trim(strKEY)) <> CStr(Trim(txtTahun.Text))))
If strTahun <> Nothing Then
vANSWER = MsgBox("Data sudah ada, yakin akan di replace......", vbYesNo, "Update")
If vANSWER = vbYes Then
cSQL = "UPDATE MS_UMR SET Sehari = CONVERT(money, '" & Val(Format(txtSehari.Text, formatSAVE)) & "'), Sebulan = CONVERT(money, '" & Val(Format(txtSebulan.Text, formatSAVE)) & "'), Nomor = '" & Trim(txtNoKeputusan.Text) & "' WHERE TAHUN = '" & Trim(txtTahun.Text) & "'"
adcLEDGER.Execute(cSQL)
showdata()
bersihForm()
Else
showdata()
bersihForm()
End If
Else
cSQL = "INSERT INTO MS_UMR(TAHUN,SEHARI,SEBULAN,NOMOR) VALUES('" & Trim(txtTahun.Text) & "', CONVERT(money,'" & Val(Format(txtSehari.Text, formatSAVE)) & "'), CONVERT(money,'" & Val(Format(txtSebulan.Text, formatSAVE)) & "'),'" & Trim(txtNoKeputusan.Text) & "')"
adcLEDGER.Execute(cSQL)
showdata()
bersihForm()
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub txtSehari_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtSehari.LostFocus
txtSehari.Text = Format(Convert.ToDouble(txtSehari.Text), "#,###0.00")
End Sub
When i tray to input success, But when i cek in my database with field data type money not i want. Example:
Result:
- I want: 10,000.00(My application) - 10000(My database with data type money), But that appears 10(in my database with data type money). Why??
What's wrong with my code???
Thank's for your answer my question...