Solved

Passing an ado command to a function

Posted on 2001-07-26
7
143 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses
Course of the Month7 days, 5 hours left to enroll

623 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