Private Sub Command1_Click()
Dim conn1 As New ADODB.Connection
Dim cmd1 As New ADODB.Command
Dim rs1 As New ADODB.Recordset
Dim amnt As Double
Dim d_value As Double
Dim accessconnect As String
Dim accnt_no As String
Dim stSQL As String
accessconnect = " Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=master;Data Source=POOJA-D4FD585E2\SQL2000"
conn1.ConnectionString = accessconnect
conn1.Open
accnt_no = Val(Text1.Text)
Text2.Text = amnt
If Len(Text1.Text) > 0 And Len(Text2.Text) > 0 Then
cmd1.ActiveConnection = conn1
cmd1.CommandText = " select balance from account where account_number= ' " & accnt_no & " ' "
Set rs1 = cmd1.Execute
dValue = rs1("balance")
stSQL = " update account set balance = balance + ' " & amnt & " ' where account_number = ' " & accnt_no & " ' "
conn1.Execute stSQL
conn1.Close
MsgBox (" AMOUNT DEPOSITED SUCCESSFULLY ")
Else
MsgBox ("Enter some value")
End If
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If Not ((KeyAscii >= 48 And KeyAscii <= 57) Or KeyAscii = 45 Or (KeyAscii >= 65 And KeyAscii <= 90)) Then
MsgBox "enter proper values!"
KeyAscii = 0
End If
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If Not ((KeyAscii >= 48 And KeyAscii <= 57) Or KeyAscii = 127 Or KeyAscii = 8) Then
MsgBox "enter proper value"
KeyAscii = 0
End If
End Sub
This code fails to update database any suggestions??? Attaching error screenshot
Attached File(s)
-
VBerror.bmp (898.65K)
Number of downloads: 23

New Topic/Question
Reply



MultiQuote








|