Hello,
I am trying to find out how to write code in Visual Basic that will update a table in SQL. I already have the database in SQL open, but the problem I have is the actual update portion of the code. Can anyone help me
Here is a sample of my code:
Function update()
'This function allows you to update and change specified records and columns in tables in
'the databases provided
' These variables store the text of the file.
Dim FHA_Case As String
Dim SeqNumber As String
Dim SSN, LName, FileNum, FName As String
Dim name, Street, City, State, Zip As String
Dim SQL1, SQL2 As String
Dim rs1 As New ADODB.Recordset
Set rs1 = New ADODB.Recordset
Dim rs2 As New ADODB.Recordset
Set rs2 = New ADODB.Recordset
Dim cnn As New ADODB.Recordset
cnn.Open "Provider=SQLOLEDB.1;Password=simple;Persist Security Info=True;User ID=sa;Initial Catalog=HUDGUISQL;Data Source=HOST\SQLEXPRESS;"
With rs1
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.LockType = adLockPessimistic
End With
SQL1 = "Select * from [ToHUD-FISR1132C-CD57];"
rs1.Open SQL1, cnn, adOpenKeyset, adLockPessimistic
Do While Not rs1.EOF
FHA_Case = rs1![CaseNum]
SeqNumber = rs1![SeqNum]
If Not rs2.EOF Then
rs2.Edit
rs2!BatchID = rs1!BatchIDNumA
rs2!ClmntSSN = rs1!ClmntSSNEIN
rs2!ClinType = "CC"
rs2.update
End If
rs1.MoveNext
rs2.Close
Loop
rs1.Close
cnn.Close
End Function
The error that I am getting says "Method or data member not found" for the line: "rs2.Edit"