Good day, I'm not even sure if I have the correct term for my post TITLE but I will try to explain it further.
1. When I am trying to copy a record in a table and insert it into a new table(another database) what I usually do is this:
Question 1: Is there any issue/problem whith this? Especially the locking of the database when inserting.
2. And sometimes I do the Insert using this process:
Question2: What is the best way/process to use?
Question3: What are the disadvantage/advantage?
Or should it really be compared?
I appreciate any support/advise/comments you can give
Thank you
Hudas
1. When I am trying to copy a record in a table and insert it into a new table(another database) what I usually do is this:
Code:
Dim db as database
Dim strSQL as string
Set db = currentdb
strSQL = "Insert Into Table1 Select * From [MS Access;DATABASE=" & Thepath and name of the database here & ";pwd=" & PasswordHere & "].[Table1] Where ID = 1"
db.Execute strSQL, dbFailOnError
Set db = nothing
2. And sometimes I do the Insert using this process:
Code:
Dim strConn As String
Dim conn as ADODB.Connection
Dim cmd as ADODB.Command
Dim strSQL as String
strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Thepath and name of the database here & ";Jet OLEDB:Database Password=" & PasswordHere & ""
conn.Open strConn
strSQL = "Insert Into Table1 (Column1,Column2,Column3) Values ([Column1],[Column2],[Column3])"
Set cmd = New ADODB.Command
With cmd
.ActiveConnection = conn
.CommandType = adCmdText
.CommandText = strSQL
.Parameters.Append .CreateParameter("Column1", adVarChar, adParamInput, 1000, Me!tbxColumn1)
.Parameters.Append .CreateParameter("Column1", adVarChar, adParamInput, 250, Me!tbxColumn2)
.Parameters.Append .CreateParameter("Column1", adVarChar, adParamInput, 250, Me!tbxColumn2)
.Execute , , adExecuteNoRecords
End With
conn.close
Question3: What are the disadvantage/advantage?
Or should it really be compared?
I appreciate any support/advise/comments you can give
Thank you
Hudas