Solved

Passing an ado command to a function

Posted on 2001-07-26
7
142 Views
Last Modified: 2013-11-23
How do I pass an ado delete command to a function?
0
Comment
Question by:JezzaKashel
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 

Expert Comment

by:Alon_h
ID: 6321186
Hi JezzaKashel.

Like that :

Function Func(tmp As ADODB.Recordset)
   ...
End Function

0
 
LVL 4

Expert Comment

by:VincentLawlor
ID: 6321202
Dim cmd as ADODB.Command

cmd.CommandText = "DELETE * FROM X WHERE Y = Z"

Sub DoSomethingWithCommand(cmd as ADODB.Command)

    cmd.ActiveConnection = connection
    cmd.Execute

End Sub

Vin.
0
 

Author Comment

by:JezzaKashel
ID: 6321247
These don't seem to work. I either get an invalid qualifer message, or type mismatch. A standard select command works perfectly
0
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 

Expert Comment

by:GrahamAtJobserve
ID: 6321346
Have you coded up your delete statement properly? Try cutting and pasting it into an access query or sqlserver query analyser
0
 
LVL 6

Accepted Solution

by:
kahlean earned 100 total points
ID: 6321391
I would suggest that you pass your delete sql query as string instead of a ado command. This prove to be much easier.


To call this function

DeleteRecordset <dsn name>, <SQL query>

Example

Dim SQL As String

SQL = DELETE * FROM A"

DeletRecordset bibliodsn, SQL

********************************************************************

Public Sub DeleteRecordset(ByVal ConnectionString As String, ByVal Source As String)

On Error GoTo ErrorHandler

    objConnection.CursorLocation = adUseClient
    objConnection.Open ConnectionString, "sa", ""

    Set objCommand = New ADODB.Command
    objCommand.CommandType = adCmdText
    objCommand.CommandText = Source
    Set objCommand.ActiveConnection = objConnection
   
    objCommand.Execute (Source)
   
    Set objCommand = Nothing
    objConnection.Close
   
End Sub

***********************************************************
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7161556
Hi JezzaKashel,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept kahlean's comment(s) as an answer.

JezzaKashel, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0
 
LVL 1

Expert Comment

by:Computer101
ID: 7182421
Comment from expert accepted as answer

Computer101
E-E Moderator
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question