1 Replies - 2106 Views - Last Post: 30 September 2012 - 09:32 AM Rate Topic: -----

#1 Poojaaa  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 29-September 12

Extracting a particular value from sql2000 database & then updatin

Posted 30 September 2012 - 06:03 AM

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

Is This A Good Question/Topic? 0
  • +

Replies To: Extracting a particular value from sql2000 database & then updatin

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9570
  • View blog
  • Posts: 36,240
  • Joined: 12-June 08

Re: Extracting a particular value from sql2000 database & then updatin

Posted 30 September 2012 - 09:32 AM

Do not create duplicate topics. Closing
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1