I tried Googling this but I get a whole lot of replies about running
the SQL statement in VB via ADO.
All I want to do is run an existing ACCESS 2000 query from VB with no
information returned to VB. I am presuming that I would use
Automation somehow.
Thanks in advance. 12 34838
Hmm... you read the book... how about the manual this time...
Straight outta Compton... no, wait, the help file:
Execute Method (ADO Connection)
Executes the specified query, SQL statement, stored procedure, or
provider-specific text.
Syntax
For a non-row-returning command string:
connection.Exec ute CommandText, RecordsAffected , Options
For a row-returning command string:
Set recordset = connection.Exec ute (CommandText, RecordsAffected ,
Options)
Return Value
Returns a Recordset object reference.
Parameters
CommandText A String value that contains the SQL statement, table
name, stored procedure, a URL, or provider-specific text to execute.
RecordsAffected Optional. A Long variable to which the provider
returns the number of records that the operation affected.
Options Optional. A Long value that indicates how the provider should
evaluate the CommandText argument. Can be one or more CommandTypeEnum
or ExecuteOptionEn um values.
Remarks
Using the Execute method on a Connection object executes whatever query
you pass to the method in the CommandText argument on the specified
connection. If the CommandText argument specifies a row-returning
query, any results that the execution generates are stored in a new
Recordset object. If the command is not a row-returning query, the
provider returns a closed Recordset object.
On 9 Jul 2005 19:08:44 -0700, pi********@hotm ail.com wrote: Hmm... you read the book... how about the manual this time...
Straight outta Compton... no, wait, the help file:
Execute Method (ADO Connection)
Nothing like an answer from a wiseguy that's wrong. Maybe you should
try reading the question.
How do I run a query that EXISTS IN ACCESS 2000 FROM VB?
As I suspected in the original post, it can be done via Automation
using the Access Application object.
Thanks.
On Sun, 10 Jul 2005 18:33:50 GMT, Bookreader <bo***********@ yahoo.com>
wrote: On 9 Jul 2005 19:08:44 -0700, pi********@hotm ail.com wrote:
Hmm... you read the book... how about the manual this time...
Straight outta Compton... no, wait, the help file:
Execute Method (ADO Connection)
Nothing like an answer from a wiseguy that's wrong. Maybe you should try reading the question.
How do I run a query that EXISTS IN ACCESS 2000 FROM VB?
As I suspected in the original post, it can be done via Automation using the Access Application object.
Thanks.
Good, now both of you can feel superior to the other and everyone is
happy!
David
On 10 Jul 2005 15:23:02 -0500, not@here (David Schofield) wrote: Good, now both of you can feel superior to the other and everyone is happy! David
Actually, I knew I shouldn't have even responded to that guy. But, I
did allow the third poster an opportunity to feel superior to both of
us! (hardee har)
I'd still like an exact answer to my original question, if you would
please.
Here's the code I have so far:
Dim objAccess As Access.Applicat ion
Set objAccess = New Access.Applicat ion
'MsgBox objAccess.Repor ts.Count
objAccess.OpenC urrentDatabase "C:\Current Database\new.md b"
objAccess.Visib le = True
objAccess.DoCmd .OpenQuery ("Create_Invoic e_Footer")
objAccess.Run ("Create_Invoic e_Footer")
Are both the OpenQuery and Run lines needed?
Is it possible to get any resulting error message back from Access or
know that the query was successful?
Thanks again.
On Sun, 10 Jul 2005 20:31:32 GMT, New Guy <Ne****@yahoo.c om> wrote: I'd still like an exact answer to my original question, if you would please.
Here's the code I have so far:
Dim objAccess As Access.Applicat ion Set objAccess = New Access.Applicat ion 'MsgBox objAccess.Repor ts.Count
objAccess.OpenC urrentDatabase "C:\Current Database\new.md b" objAccess.Visib le = True objAccess.DoCmd .OpenQuery ("Create_Invoic e_Footer") objAccess.Run ("Create_Invoic e_Footer")
Are both the OpenQuery and Run lines needed? Thanks again.
I did find out that I don't need the "objAccess. Run
("Create_Invoic e_Footer")" line.
On Sun, 10 Jul 2005 20:43:51 GMT, New Guy <Ne****@yahoo.c om> wrote: On Sun, 10 Jul 2005 20:31:32 GMT, New Guy <Ne****@yahoo.c om> wrote:
I'd still like an exact answer to my original question, if you would please.
Here's the code I have so far:
Dim objAccess As Access.Applicat ion Set objAccess = New Access.Applicat ion 'MsgBox objAccess.Repor ts.Count
objAccess.OpenC urrentDatabase "C:\Current Database\new.md b" objAccess.Visib le = True objAccess.DoCmd .OpenQuery ("Create_Invoic e_Footer") objAccess.Run ("Create_Invoic e_Footer")
Are both the OpenQuery and Run lines needed? Thanks again.
I did find out that I don't need the "objAccess. Run ("Create_Invoi ce_Footer")" line.
Hi
You put me in an embarrassing position.
Your original post said
"All I want to do is run an existing ACCESS 2000 query from VB with no
information returned to VB"
That implied that you are programming a VB program and want to run an
stored action query (ie insert (append), update or delete) in a JET
(ie Access) database. The way to do this is as PietLinden suggests,
though you could use DAO instead of ADO.
But the example code you since posted suggests you are going to follow
this up with other things in a full Access environment, eg create
reports.In this case automation is certainly indicated.
I suggest you go to http://support.microsoft.com/default...NoWebContent=1
"Microsoft Office 2000 automation Help file is available in the
Download Center."
the download gives many examples of automating Access 2000.
Can't you do it all in one instance of Access and avoid automation? My
own experiences are it is nothing but trouble, eg it leaves dangling
references and the called aplication doesn't close but sits there
invisibly; any failures are hard to recover from; etc etc. Access 2000
also has many bugs in this area and maybe not all were cured by
service packs. I would prefer to use the shell method if I had to.
David
On 10 Jul 2005 18:04:02 -0500, not@here (David Schofield) wrote: I suggest you go to http://support.microsoft.com/default...NoWebContent=1 "Microsoft Office 2000 automation Help file is available in the Download Center." the download gives many examples of automating Access 2000.
Thanks for this link. That's what I really need.
Can't you do it all in one instance of Access and avoid automation? My own experiences are it is nothing but trouble, eg it leaves dangling references and the called aplication doesn't close but sits there invisibly; any failures are hard to recover from; etc etc. Access 2000 also has many bugs in this area and maybe not all were cured by service packs. I would prefer to use the shell method if I had to. David
I'm not sure I get your question about one instance of Access.
I just want to have the user click a button in a VB program to run a
query that resides in Access. Where does more than one instance of
Access fit into this?
All I want the user to know is that he has to push the button.
Thanks.
On Sat, 09 Jul 2005 22:52:53 GMT, Bookreader <bo***********@ yahoo.com> wrote:
¤ I tried Googling this but I get a whole lot of replies about running
¤ the SQL statement in VB via ADO.
¤
¤ All I want to do is run an existing ACCESS 2000 query from VB with no
¤ information returned to VB. I am presuming that I would use
¤ Automation somehow.
¤
You can use ADO (Microsoft ActiveX Data Objects 2.x Library) to do this:
Dim strConnectionSt ring As String
Dim objConn As ADODB.Connectio n
Dim objCommand As ADODB.Command
strConnectionSt ring = "Provider=Micro soft.Jet.OLEDB. 4.0;" & "Data Source=e:\My
Documents\db1.m db;" & _
"Jet OLEDB:Engine Type=4"
Set objConn = New ADODB.Connectio n
objConn.Open strConnectionSt ring
Set objCommand = New ADODB.Command
objCommand.Acti veConnection = objConn
' Assign to ADO Command object
objCommand.Comm andText = "qdelTable1 0"
objCommand.Comm andType = adCmdStoredProc
objCommand.Exec ute
objConn.Close
Set objCommand = Nothing
Set objConn = Nothing
Paul
~~~~
Microsoft MVP (Visual Basic)
On Mon, 11 Jul 2005 08:29:57 -0500, Paul Clement
<Us************ ***********@sws pectrum.com> wrote: On Sat, 09 Jul 2005 22:52:53 GMT, Bookreader <bo***********@ yahoo.com> wrote:
¤ I tried Googling this but I get a whole lot of replies about running ¤ the SQL statement in VB via ADO. ¤ ¤ All I want to do is run an existing ACCESS 2000 query from VB with no ¤ information returned to VB. I am presuming that I would use ¤ Automation somehow. ¤
You can use ADO (Microsoft ActiveX Data Objects 2.x Library) to do this:
Dim strConnectionSt ring As String Dim objConn As ADODB.Connectio n Dim objCommand As ADODB.Command
strConnectionSt ring = "Provider=Micro soft.Jet.OLEDB. 4.0;" & "Data Source=e:\My Documents\db1. mdb;" & _ "Jet OLEDB:Engine Type=4"
Set objConn = New ADODB.Connectio n objConn.Open strConnectionSt ring
Set objCommand = New ADODB.Command
objCommand.Acti veConnection = objConn
' Assign to ADO Command object objCommand.Comm andText = "qdelTable1 0" objCommand.Comm andType = adCmdStoredProc
objCommand.Exec ute
objConn.Close
Set objCommand = Nothing Set objConn = Nothing
Paul ~~~~ Microsoft MVP (Visual Basic)
I see. A query existing in ACCESS is a stored procedure.?
Does this return an error message if the statement fails?
Is ADO preferable to the Acess.Applicati on method below. Just for my
education, can you tell me why ADO is better?
Dim objAccess As Access.Applicat ion
Set objAccess = New Access.Applicat ion
'MsgBox objAccess.Repor ts.Count
objAccess.OpenC urrentDatabase "C:\Current Database\new.md b"
objAccess.Visib le = True
objAccess.DoCmd .OpenQuery ("Create_Invoic e_Footer")
objAccess.Run ("Create_Invoic e_Footer")
Thanks. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jahmil Richardson |
last post by:
Attempting to query MS Access database with the ODBC drivers for PHP. When
using the LIKE statement no records are returned.
Example:
$query = " Select * From Dispatch Where Customer Like '*A*' ";
$result = odbc_prepare($db,$query);
odbc_execute($result);
Does anyone out there know the syntax that I should be using for the Like
|
by: meyvn77 |
last post by:
I wrote a bunch of SQL statement in SQL SERVER and now im trying to do
the same thing in access. OMG what a pain that Access can't handle
updates or CAST() the way SQL server can. OK I thought I wrote
everything in Ansi standard SQL statement so it should be compatable?
right?
The problem is i'm going from a relational format to a flat file fomat
and this is only a 15th of the accual query. Please tell me their is a
way to use this type...
|
by: abhishekjethwani |
last post by:
How to write a query to access tree structure form multi table. I m having five tables from them first table give me a data which act as the parameter for query for the second table and the two tables will give me parameter for the third and so on.
at present i m writing five query and sending parameter to each query but i want an efficient way for this.
its a parent child type relation.
|
by: candicemc |
last post by:
Can anyone help me please?!
I am a beginner and i am in desperate need of help. I have to create an insert query in access using a table i've already created called "madlibs" Then I have to create a code in vb.net to call this query when a user clicks the submit button. The objective is to have the database automatically updated when a user submits information. The problem is that I don't know where to begin, so if someone could just point me...
|
by: Jim |
last post by:
I'm a vb.net newbie.
I have an query that is entirely within an Access database. It's a
simple update query - "usp_Append_tbl_RefNos". It works in Access,
How can I run that query from a vb .net program? I have an vb app that
does update another Access table using a stored procedure but it updates
fields with info from a file.
I've tried the code below and I get an error on the ExecuteNonQuery() -
| |
by: ashutoshvyas |
last post by:
I am designing a data report in VB6. In data environment it is possible to selet tables and 'select quries'. But I want to generate a report based on parameters passed by user, so i had created a parameter query in ACCESS which is not available in the properties of command1.
SQL code of query is as under :
SELECT Customers.account_no, Customers.card_no, Customers.name, payments.amount, payments.payment_date, dlt_3., total_amount.
FROM...
|
by: rune |
last post by:
Hi
I'm trying to convert an SQL Query from Access to SQL Server. The
Access Query goes like this:
SELECT Format(EntryDate, 'ddd mm dd') AS
FROM JournalEntries
This query returns the name of the day followed by month and date (Su
aug 21)
|
by: anthony |
last post by:
In Access 2007, why does a query field designed as Term: !
! return 00:00:00 when cboTerm actually contains
08SP. This works as expected in Access 2003?
|
by: csin |
last post by:
I have an Access DB backend for the application I am running, I want to use the built in ability in Access to remove duplicate entries...
Say I have table1 with fields field1 field2 and field3, none of the fields are indexed without duplicates for a reason...
The way I remove duplicates is to do an append query into an identical table that has one of the fields set to indexed no duplicates.
If I run this query in Access directly I get a...
|
by: jenniferhelen |
last post by:
I am working with a query that has 6 columns and 101 rows; I would like to transpose the rows and columns. I have tried using a crosstab query but Access limits the row "fields" to 3 and this was not producing the desired output. I saw a comment in a thread about using a pseudo row field as a work around but I do not understand how this works.
Another option I tried is from the following link and attempting method 2: ...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |