473,398 Members | 2,389 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Using MS Access as a front end and trying to run a script

Does anyone know how I can use vba in access to run a script that is stored
as a file. I can make a connection to mysql database and run sql statements
but this sql statement is very long (creates many tables with hundreds of
fields). I can run the script in the mysql interface but I want to do this
from my access front end to make it easy for the user to set up the tables.
I need something like
myconnection.execute ("c:\myfiles\myscript.sql)
but obviously this does not work.
Alex
Jul 20 '05 #1
1 1953
On Sun, 02 Jan 2005 22:44:01 +0000, Paradigm wrote:
Does anyone know how I can use vba in access to run a script that is
stored as a file. I can make a connection to mysql database and run sql
statements but this sql statement is very long (creates many tables with
hundreds of fields). I can run the script in the mysql interface but I
want to do this from my access front end to make it easy for the user to
set up the tables. I need something like myconnection.execute
("c:\myfiles\myscript.sql) but obviously this does not work.
Alex


The best way to use Access/VBA with MySQL is to use the ODBC driver and
create linked tables to your MySQL tables. Having accomplished this, you
can treat your MySQL database as you would an ordinary Access database.

Your "myconnection.execute" example would not work because it requires a
string argument that is one single SQL statement. There are
several things you can do.

You can park each SQL statemnt in your script in an individual Access
query. Name your queries Query_01, Query_02, ... Query_NN. Now you can use
your VBA to loop execute each query in turn. NB: Make sure to define your
queries as sql PASSTHROUGH if you are using pure MySQL syntax.

OR

Write your VBA code to read the the [myscript.sql] file and pass each
single query statement to the connection .execute method in turn. All you
need do is assemble each line into a string (DIM sql As String). When you
encounter the ";" terminating line, you stop reading the file,
"myconnection.execute sql", sql = "", then continue reading the file.
Again, if you are using MySQL syntax, you need to be sure you define your
connection as type PASSTHROUGH.

It really isn't complicated if you are familiar with VBA together with ADO
or DAO. I use Access all the time to get around the MySQL 4.0x lack of
stored procedures.

If you get stuck, give another shout.
Thomas Bartkus

Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Richard Muller | last post by:
Hi All, I've got the ASP script shown below that complains as follows: Microsoft OLE DB Provider for ODBC Drivers (0x80004005) Data source name not found and no default driver specified...
38
by: Remco Groot Beumer | last post by:
Hello, I'm trying to decide if the following situation would be workable: Generate an MS Access Front End (which will run localy on client computers), which will link to a DBMS (SQL server or...
13
by: Stumped and Confused | last post by:
Hello, I really, really, need some help here - I've spent hours trying to find a solution. In a nutshell, I'm trying to have a user input a value in form's textfield. The value should then be...
121
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
10
by: Scott | last post by:
I have written an Access application that our employees use on a daily basis to enter information. It's comprises of a series of forms, a few data integrity check queries that run in the...
1
by: Jim Devenish | last post by:
I am continuing my exploration about upsizing to SQLServer from Access 2000. I have a split database with a front-end and a back-end, each of which is A2K. I have spent some time in bookshops...
5
by: IkBenHet | last post by:
Hello, I use this script to upload image files to a folder on a IIS6 server: ******************* START UPLOAD.ASPX FILE ********************** <%@ Page Language="VB" Debug="true" %>
35
by: robert d via AccessMonster.com | last post by:
I was asked to provide a proposal. I provided a proposal on my application and the prospective client likes what I have but is wary of it having been developed in Access. I don't understand this...
2
by: PokerJoker | last post by:
on click of a link, i'm sending an ajax call to the server, grabbing relevant data, and trying to display it by adding a datagrid to a hidden div, making it visible, and moving it to the front. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
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,...
0
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...
0
jinu1996
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...
0
agi2029
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.