(Access 2000/ODBC to MySQL tables)
Hi,
I am getting the run time erro 3027 and it says that "cannot update: database or object is read only." Does anyone see any errors in my code below? Thanks for the help!
My code is - outfilename = "ls." & field1 & value1a & "_" & value1b & ".txt"
-
MsgBox "outfilename is " & outfilename
-
strSQL = "SELECT * INTO [Text;HDR=YES;DATABASE=D:\\AccessData\\myDatabase].outfilename FROM myTable;"
-
-
DoCmd.RunSQL strSQL
11 4930
(Access 2000/ODBC to MySQL tables)
Hi,
I am getting the run time erro 3027 and it says that "cannot update: database or object is read only." Does anyone see any errors in my code below? Thanks for the help!
My code is - outfilename = "ls." & field1 & value1a & "_" & value1b & ".txt"
-
MsgBox "outfilename is " & outfilename
-
strSQL = "SELECT * INTO [Text;HDR=YES;DATABASE=D:\\AccessData\\myDatabase].outfilename FROM myTable;"
-
-
DoCmd.RunSQL strSQL
Hi. I tried out a query based on your code (without the other DB) which tried to connect to the back-end DB; I didn't have a test DB set up to replicate what you are trying to do, but since the RunSQL did what it was supposed to do it appears that the VB code is OK. I can't say that your SQL update is, because it depends whether the other DB recognises it as a valid SQL statement to respond to.
As the SQL query got to the stage where it was passed through to the other DB it suggests to me that either 1) there is a problem at the myDatabase end, or 2) the permissions currently set do not allow you to update the other DB, or 3) this type of SELECT ... INTO is not a valid update query for your other DB. I cannot comment on MySQL (not used it myself), and with no data about whether you have used this type of update before all I can say is that Access is doing what it is supposed to do.
-Stewart
Hi. I tried out a query based on your code (without the other DB) which tried to connect to the back-end DB; I didn't have a test DB set up to replicate what you are trying to do, but since the RunSQL did what it was supposed to do it appears that the VB code is OK. I can't say that your SQL update is, because it depends whether the other DB recognises it as a valid SQL statement to respond to.
As the SQL query got to the stage where it was passed through to the other DB it suggests to me that either 1) there is a problem at the myDatabase end, or 2) the permissions currently set do not allow you to update the other DB, or 3) this type of SELECT ... INTO is not a valid update query for your other DB. I cannot comment on MySQL (not used it myself), and with no data about whether you have used this type of update before all I can say is that Access is doing what it is supposed to do.
-Stewart
Hi Stewart!
Thank you so much for your trying out my code.
One thing that I don't understand is that... if the file name is not a variable, then it renders a txt file OK. For instance, - strSQL = "SELECT * INTO [Text;HDR=YES;DATABASE=D:\\AccessData\\myDatabase].outfilename.txt FROM myTable;"
-
-
DoCmd.RunSQL strSQL
It creates a txt file with filtered data with no problem. So it seems to be that getting filename from the variables are causing the problem. I am under stress a bit since I have to solve this problem within 2, 3 days. Whew... Any idea you can think of? Thanks again!
... if the file name is not a variable, then it renders a txt file OK.
Hi, and well done for going straight to the heart of the problem - placing the variable name within the string! VB can't do the substitution that way. I didn't see it before, not being familiar with the MySQL SELECT...INTO construct - but it becomes so obvious now you have mentioned it.
Try - strSQL = "SELECT * INTO [Text;HDR=YES;DATABASE=D:\\AccessData\\myDatabase]." & outfilename & " FROM myTable;"
Cheers
Stewart
Hi, and well done for going straight to the heart of the problem - placing the variable name within the string! VB can't do the substitution that way. I didn't see it before, not being familiar with the MySQL SELECT...INTO construct - but it becomes so obvious now you have mentioned it.
Try - strSQL = "SELECT * INTO [Text;HDR=YES;DATABASE=D:\\AccessData\\myDatabase]." & outfilename & " FROM myTable;"
Cheers
Stewart
Wow! Thank you, thank you, thank you!
I owe you thousand times thank you, Stewart!
It works greatly!
That little thingeeee caused me such agony for many days.
Thanks again to you and to "thescript.com" !!
You are very welcome, loisk, and thank you for your kind words. Really, you pointed out where the problem was yourself, so well done for that.
I am very glad indeed that your query is now working as intended.
Regards
Stewart
You are very welcome, loisk, and thank you for your kind words. Really, you pointed out where the problem was yourself, so well done for that.
I am very glad indeed that your query is now working as intended.
Regards
Stewart
I really appreciate your help!
Hi Stewart,
The previously solved problem with your help gave a birth another question.
The variable for my outputfilename is not rendering properly if I use it with IF statement. I am sure that I am not doing something right in building a string statement. - outfilename = "ls." & field1 & value1a & "_" & value1b & ".txt"
-
MsgBox "outfilename is " & outfilename
-
strSQL = "SELECT * INTO [Text;HDR=YES;DATABASE=D:\\AccessData\\myDatabase]. " & outfilename & "FROM myTable;"
-
-
DoCmd.RunSQL strSQL
It works just fine to create a text file with the file name I want it to be.
Then, I have to construction a conditional statement for the filename, outfilename. When I use the filename variable within the IF statement, it gives out an error. For example, - if (values1a) > "" and (value1b) = "" then
-
outfilename = "ls." & field1 & value1a & ".txt"
-
else
-
if (values1a) = "" and (value1b) > "" then
-
outfilename = "ls." & field1 & value1b & ".txt"
-
end if
-
-
MsgBox "outfilename is " & outfilename
-
strSQL = "SELECT * INTO [Text;HDR=YES;DATABASE=D:\\AccessData\\myDatabase]. " & outfilename & "FROM myTable;"
-
-
DoCmd.RunSQL strSQL
The MsgBox is not showing the outfilename at all.
Do you find any fault in the code? Thanks!
Hi again Loisk. Your condition tests are not quite right, and as a result neither branch of your IF statement sets the outfilename (hence blank name in messagebox). Your IFs are also missing an END IF, correctible by changing the middle ELSE to an ELSEIF - if (Nz(values1a)) <> "" and NZ((value1b)) = "" then
-
outfilename = "ls." & field1 & value1a & ".txt"
-
elseif NZ(values1a) = "" and NZ(value1b) <> "" then
-
outfilename = "ls." & field1 & value1b & ".txt"
-
end if
The Nz function is used to substitute an empty string if the argument passed to it is null.
Please note that your code does not cover the situation where values1a and value1b are both empty.
Hope this helps.
-Stewart
Hi again Loisk. Your condition tests are not quite right, and as a result neither branch of your IF statement sets the outfilename (hence blank name in messagebox). Your IFs are also missing an END IF, correctible by changing the middle ELSE to an ELSEIF - if (Nz(values1a)) <> "" and NZ((value1b)) = "" then
-
outfilename = "ls." & field1 & value1a & ".txt"
-
elseif NZ(values1a) = "" and NZ(value1b) <> "" then
-
outfilename = "ls." & field1 & value1b & ".txt"
-
end if
The Nz function is used to substitute an empty string if the argument passed to it is null.
Please note that your code does not cover the situation where values1a and value1b are both empty.
Hope this helps.
-Stewart
Hi Stewart again!
Sorry for the incompleted code which I just typed it while it was written, but I have END IF in my real code. (My server is down for other reason right now, so I didn't copy from the real code.) Anyhow, thanks for your quick reply. I will retry with your code as soon as the server is back, and will let you know. Thanks again!
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: leroybt.rm |
last post by:
Can someone tell me how to run a script from a interactive shell
I type the following:
>>>python filename
>>>python filename.py
>>>run filename
>>>run filename.py
>>>/run filename
>>>/run filename.py
|
by: Ed |
last post by:
Hello,
I took a course in asp about 2 years ago and I was
practicing with IIS 5.0. Then I put it down for a while.
Now trying to get back to it. I can't run asp files from
subdirectories of my root directory, but I can run asp
files from the root directory of my website and I can run
htm files from the subdirectories. If I run
localhost/mytest.asp
|
by: Jenna Olson |
last post by:
Hi all-
I've never seen this particular issue addressed, but was wondering if
there's anything to support one way or another. Say I have a class:
class ManipulateData
{
public:
ManipulateData(const char* Path-To-Some-Text-File)
{ ... }
|
by: mg |
last post by:
How can I run an .exe using C# from within the code behind of a WebForm app?
|
by: billr |
last post by:
I have developed a small API for taking care of a lot of boiler plate stuff
in a multi formed windows application, for example setting up a messaging
thread framework.
New Forms, in the appllication using the API, are subclassed to a Form
contained within the API, and they are controlled (controlled in this
instance means, kept alive, displayed and hidden) at runtime by a thread
whose responsibility is this sole task.
In order to run...
| |
by: Bob Day |
last post by:
Using vs2003, vb.net
I start a thread, giving it a name before start. Code snippet:
'give each thread a unique name (for later identification)
Trunk_Thread.Name = "Trunk_0_Thread"
' allow only 1 thread per line
Trunk_Thread.ApartmentState = ApartmentState.STA
|
by: shank |
last post by:
What is the proper syntax to run this command line in ASP?
wzzip.exe File.zip File.txt
thanks
|
by: Bryan |
last post by:
How can i run a bit of code straight from the IDE? Right now i make a
temporary button and put the code behind that, then i run debug mode
and click on the button. Is there a way to highlight some code and
tell it to run that? Is there a "scratchpad" type window like in VBA
where I can write some simple code to be executed? Thanks for the help
in advance
|
by: Lee Crabtree |
last post by:
I remember when I was first getting into .NET Forms programming that
there was a rather emphatic rule about not constructing a form before
calling Application.Run with it. So this:
Application.Run(new Form1());
was okay, but this:
Form1 form = new Form1();
|
by: mxdevit |
last post by:
Task: run application from ASP.NET
for example,
you have a button on ASP.NET page, when press this button - one
application is invoked.
the code to run application (for example, notepad) is (on C#)
System.Diagnostics.Process.Start("notepad");
|
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: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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: 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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |