Hello Everyone,
I am having a little bit of troubles storing data into a database. I will paste part of the code for simpler explanations.
I send data from a server to the host application and try to update it by using recordsets.
The first to tables work fine but when I try with the third one it crashes. Any ideas?
It is an Access Database, and the ID is an autonumber field, while the text field is a text field.
Any help welcome
Thanks
Paolo
Dim rs As ADODB.Recordset
Dim con As ADODB.Connection
Select case
Case 1
Case 2
.....
Case "DefPayTypes"
'Empty the table
''Status = "Preparing database to import data."
SQLStr = "DELETE * FROM DefPayTypes"
con.Execute SQLStr
''Status = "Importing data"
Do Until rs.EOF
'Insert the values into the table
SQLInsert = "INSERT INTO DefPayTypes (ID,Text)"
SQLInsert = SQLInsert & " VALUES("
SQLInsert = SQLInsert & rs!ID & ","
SQLInsert = SQLInsert & Chr(34) & rs!Text & Chr(34)
SQLInsert = SQLInsert & ")"
Debug.Print SQLInsert
con.Execute SQLInsert
rs.MoveNext
Loop
End Select
I am having a little bit of troubles storing data into a database. I will paste part of the code for simpler explanations.
I send data from a server to the host application and try to update it by using recordsets.
The first to tables work fine but when I try with the third one it crashes. Any ideas?
It is an Access Database, and the ID is an autonumber field, while the text field is a text field.
Any help welcome
Thanks
Paolo
Dim rs As ADODB.Recordset
Dim con As ADODB.Connection
Select case
Case 1
Case 2
.....
Case "DefPayTypes"
'Empty the table
''Status = "Preparing database to import data."
SQLStr = "DELETE * FROM DefPayTypes"
con.Execute SQLStr
''Status = "Importing data"
Do Until rs.EOF
'Insert the values into the table
SQLInsert = "INSERT INTO DefPayTypes (ID,Text)"
SQLInsert = SQLInsert & " VALUES("
SQLInsert = SQLInsert & rs!ID & ","
SQLInsert = SQLInsert & Chr(34) & rs!Text & Chr(34)
SQLInsert = SQLInsert & ")"
Debug.Print SQLInsert
con.Execute SQLInsert
rs.MoveNext
Loop
End Select