I am upgrading a database application that I created a couple of years ago, so that it can operate on an SQL server. It used an Access Database previously and all my database operations used commands similar to:
sSQL = "SELECT etc", "INSERT etc", "UPDATE etc" or "DELETE etc"
Set rsado = Con.Execute(sSQL)
In my updrade (Once my connection (Con) has been set up, I have been using:
If Con.State = adStateOpen Then
With Rec
.CursorLocation = adUseClient
.Open SQL, Con, adOpenStatic, adLockBatchOptimistic
<Do what I need to do etc>
then continue.
By using comDetails as New ADODB.Command I have been able to translate some of my transactions as shown below:
With comDetails
.ActiveConnection = Con
.CommandType = adCmdText
.CommandText = "SELECT * FROM Employee etc" OR
.CommandText = "UPDATE Employee SET Employee etc" OR
.CommandText = "INSERT INTO etc"
End With
Con.Execute
HOWEVER using the command text
.CommandText = "DELETE Employee.* FROM Employee WHERE etc"
fails. The only way I can get DELETE to work is using a recordset to find a record and then using something like
Rec.Delete
Rec.UpdateBatch
I have read numerous articles from Microsoft and this forum and would like to know what is the best way to perorm these transactions (ie SELECT, UPDATE, INSERT and DELETE).
Is there a standard (??) way I can perform these transactions.
sSQL = "SELECT etc", "INSERT etc", "UPDATE etc" or "DELETE etc"
Set rsado = Con.Execute(sSQL)
In my updrade (Once my connection (Con) has been set up, I have been using:
If Con.State = adStateOpen Then
With Rec
.CursorLocation = adUseClient
.Open SQL, Con, adOpenStatic, adLockBatchOptimistic
<Do what I need to do etc>
then continue.
By using comDetails as New ADODB.Command I have been able to translate some of my transactions as shown below:
With comDetails
.ActiveConnection = Con
.CommandType = adCmdText
.CommandText = "SELECT * FROM Employee etc" OR
.CommandText = "UPDATE Employee SET Employee etc" OR
.CommandText = "INSERT INTO etc"
End With
Con.Execute
HOWEVER using the command text
.CommandText = "DELETE Employee.* FROM Employee WHERE etc"
fails. The only way I can get DELETE to work is using a recordset to find a record and then using something like
Rec.Delete
Rec.UpdateBatch
I have read numerous articles from Microsoft and this forum and would like to know what is the best way to perorm these transactions (ie SELECT, UPDATE, INSERT and DELETE).
Is there a standard (??) way I can perform these transactions.