new ABODB.Connection

MikeDBMan

Well-known Member
Joined
Nov 10, 2010
Messages
610
I created an ABODB.connection and then issue this command.
Code:
Let QueryTxt = UPDATE ProjectList SET ProcessingStatus = 'This is a test' WHERE 'Project ID' = '1080'
Set cnn = New ADODB.Connection
With cnn
    .Open "mypath\myfile"  ' I know this part is correct.    
    .Execute QueryTxt
End With

Nothing happens. The Table is ProjectList and the 2 fields are both text fields, Project ID and ProcessingStatus.

Suggestions?
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Try changing the SQl line to:

Code:
Let QueryTxt = "UPDATE ProjectList SET ProcessingStatus = 'This is a test' WHERE [Project ID] = '1080'"

I've put sq brackets round the field name.
 
Upvote 0
That solved my issue. Thanks so much! :) However, I can't seem to find the "Solved" option to show it as solved?
 
Upvote 0
The forum doesn't show threads as Solved Mike so no need to worry!

We like to keep the threads open in case someone has a better/alternative solution to add ;-)
 
Upvote 0
Just wondering. Is there a way to capture a code returned from the external connection to try to determine success or failure of the update?
 
Upvote 0
Sure thing Mike - you need to pass in a long variable with the Execute statement in the RecordsAffected argument:

Code:
Dim lngRecsAffected As Long

'...

.Execute QueryTxt, lngRecsAffected, adCmdText  'third argument specifies SQl string being passed in - not strictly necessary

Msgbox lngRecsAffected & " were updated"
 
Upvote 0

Forum statistics

Threads
1,224,570
Messages
6,179,610
Members
452,931
Latest member
The Monk

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top