473,383 Members | 1,879 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,383 software developers and data experts.

MS Access, SQL and Java

I have defined a VBA function inside a module like this:

Public Function MyFunction() As Integer
MyFunction = 2
End Function

In my Java program i have the follow:
....
String query = "SELECT * FROM MyTable WHERE ID = MyFunction()";
....
statement.execute(query);
.....

It is an MS-ACCESS database. I get the following error:
"function MyFunction is not defined" any idea why?

is it not enough to define the function in modules and then reference it from Java program in sql statemente
Feb 20 '08 #1
5 1953
sicarie
4,677 Expert Mod 4TB
I have defined a VBA function inside a module like this:

Public Function MyFunction() As Integer
MyFunction = 2
End Function

In my Java program i have the follow:
....
String query = "SELECT * FROM MyTable WHERE ID = MyFunction()";
....
statement.execute(query);
.....

It is an MS-ACCESS database. I get the following error:
"function MyFunction is not defined" any idea why?

is it not enough to define the function in modules and then reference it from Java program in sql statemente
The variable query is read exactly as you see it - MyFunction() is never called as it is considered to be part of the string variable. You need something like (though I'm not sure exactly how to interface the VB to Java...)

String s_query = "SELECT * FROM MyTable WHERE ID = " + MyFunction();

That is, of course, assuming you can properly call a VBA function from your Java code without have to instantiate anything else, and that MyFunction() returns something of type String.
Feb 21 '08 #2
BigDaddyLH
1,216 Expert 1GB
I don't think you want to try to call Vb code from Java. Why not rewrite it in Java?
Feb 21 '08 #3
due I don't want to read the entire database for processing in java. I was hoping the for that SQL statement sent, it would try to look in the module section when it saw this function call.
Feb 21 '08 #4
r035198x
13,262 8TB
due I don't want to read the entire database for processing in java. I was hoping the for that SQL statement sent, it would try to look in the module section when it saw this function call.
How would it try to look in the module section? Do you know the structure of a Java program?
Feb 21 '08 #5
BigDaddyLH
1,216 Expert 1GB
I don't know what a "module section" is, since I don't touch VBA or ACCESS. Is it a NON-STANDARD part of the database? The only clean think I can think of is that JDBC lets you call stored procedures. If you design your database with an interface made of stored procedures, you're laughing:

http://java.sun.com/docs/books/tutorial/jdbc/index.html
Especially:
http://java.sun.com/docs/books/tutor...asics/sql.html
Feb 21 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: dennis | last post by:
Hi, I need to access Java object through an ASP page. I reckon that there are two ways: 1) If the Java object is registered as a COM then access it through the ProgID using CreateObject method....
0
by: Monica Ferrero | last post by:
Hi! I'm not sure if this is the most adequate mySQL list for this post. If not, please indicat me which one I should use... I'm using Tomcat 4.1.24 with Apache 2 and MySQL 4.0.13. I have the...
12
by: Phil Powell | last post by:
<cfquery name="getAll" datasource="#request.dsn#"> SELECT U.userID, U.fname, U.lname, U.phone, U.lastLoggedIn, U.choiceId, U.experience, T.label AS teamLabel, R.label AS roleLabel FROM User U...
4
by: SJ Mo2 | last post by:
I have several Access databases that I want to publish (or make available) through our web-pages. The problem...our web server is on a Linux-Apache machine while our Access db is obviously on a...
9
by: Albretch | last post by:
.. I am trying to create a database in a MS Access DB via JDBC drivers. I have tried both sun.jdbc.odbc.JdbcOdbcDriver and ids.sql.IDSDriver From some reason both drivers Exceptions tell me...
1
by: Appelq | last post by:
I just had an outside company develop a small application using MySQL and server side Java. The application is OK (not great), and the reason for server side Java was that I need to use the app...
21
by: nihad.nasim | last post by:
Hi there, I have a database in Access that I need on the web. The web page should connect to the database and write records for certain tables and view records for others. I want to know a...
8
by: ajos | last post by:
hi frnds, im trying to convert my servlets database configuration from ms access to mysql database.however im getting some error like no driver found exception. to verify this error ive...
0
by: neuraljay | last post by:
hi everyone. I am trying to build a jsp using webwork, hibernate and mysql. And right now I am doing its unit testing. Everytime I run the test I am getting this error: Error JDBC exception on...
2
by: HeMan_Speaks | last post by:
I m currently developing a java based application and want to know how can i make client access database located on the server?
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.