473,506 Members | 11,491 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Inner Join Ms.Access in vb6

19 New Member
Hi there,
i have a project vb6. i want using inner join to join 4 tables with query select. but it's error "The SELECT statement includes a reserved word or an argument name that is misspelled or missing, or the punctuation is incorrect..

This is my script

Expand|Select|Wrap|Line Numbers
  1. QuerySelect = "SELECT a.DN, b.DIN, c.PIN, c.UserName, " _
  2.              & "b.Clock, d.ItemName, " _
  3.              & "FROM ras_Device a INNER JOIN ras_AttRecord b ON a.DN = b.DN " _
  4.              & "LEFT JOIN ras_Users c ON b.DIN = c.DIN " _
  5.              & "LEFT JOIN ras_AttTypeItem d ON d.ItemId = b.AttTypeId " _
  6.              & "WHERE b.DIN = c.DIN"
  7. rsSQL.Open QuerySelect, adoRAS
Please help me.
Thanx before.


Regards,

Octo

database use ms.access 2003
Oct 1 '10 #1
6 6750
MikeTheBike
639 Recognized Expert Contributor
Hi

First thing to do is remove the comma between d.ItemName and the FROM. I think it is expecting FROM to be a field name, which is, of course, a reserved word!?


MTB
Oct 1 '10 #2
Octo Siburian
19 New Member
Thanx Mr.Mike,

I have fixed the script, but is still error,
"Syntax error(missing operator) in query expression 'a.DN=b.DN LEFT JOIN ras_Users c ON b.DIN=c.DIN LEFT JOIN ras_AttTypeItem d ON b.AttTypeId=d.ItemId' :(
Oct 4 '10 #3
MikeTheBike
639 Recognized Expert Contributor
Hi

It is a bit difficult to have any degree of confidence in diagnosing the problem without any knoledge of the database structure or what you are trying to achieve, but I suggest some bracketing might be usfeul !
Expand|Select|Wrap|Line Numbers
  1. QuerySelect = "SELECT a.DN, b.DIN, c.PIN, c.UserName, " _
  2.         & "b.Clock, d.ItemName " _
  3.         & "FROM ((ras_Device a INNER JOIN ras_AttRecord b ON a.DN = b.DN) " _
  4.         & "LEFT JOIN ras_Users c ON b.DIN = c.DIN) " _
  5.         & "LEFT JOIN ras_AttTypeItem d ON d.ItemId = b.AttTypeId " _
  6.         & "WHERE b.DIN = c.DIN"
??

MTB
Oct 4 '10 #4
Octo Siburian
19 New Member
Thanx so much Mr.Mike, it work, the desired data has emerged,
now, i have a new question , from the previous SELECT query I want to enter back into the database with INSERT query, but every time I run the application, the old data is still in, I just want the new data are entered

QuerySelect = "SELECT a.DN, b.DIN, c.PIN, c.UserName, " & _
"b.Clock, d.ItemName " & _
"FROM ((ras_Device a INNER JOIN ras_AttRecord b ON a.DN=b.DN) " & _
"LEFT JOIN ras_Users c ON b.DIN=c.DIN) " & _
"LEFT JOIN ras_AttTypeItem d ON b.AttTypeId=d.ItemId " & _
"WHERE b.DIN=c.DIN"
rsSQL.Open QuerySelect, adoRAS

'Input pada dbSIKawan
Do While Not rsSQL.EOF
QueryInsertSIKawan = "INSERT INTO fingerprint_" _
& "(device, finger_ID, nik_kary, nama_kary, time, type)"
QueryInsertSIKawan = QueryInsertSIKawan & " VALUES('" & rsSQL(0) & "', '" & rsSQL(1) & "', " _
& "'" & rsSQL(2) & "', '" & rsSQL(3) & "', '" & rsSQL(4) & "', '" & rsSQL(5) & "')"
adoSIKawan.Execute QueryInsertSIKawan
Loop


any suggestion sir?

Regards,

octo
Oct 4 '10 #5
MikeTheBike
639 Recognized Expert Contributor
Hi

Do you get any error messages when the code executes?

What data types are the device, finger_ID, nik_kary, nama_kary, time and type fields?

If any of them are not Text data types then the sytax is incorrect. Number datatypes do not require apostrophy delimiters and date/time fields need # delimiters .

MTB
Oct 5 '10 #6
Octo Siburian
19 New Member
No sir, but when running the data is always repeating itself, but a similar data entry of repetitive,

ms.access
device = number
finger_ID = number
nik_kary = text
nama_kary = text
time = date / time
type = text

sql server
device = int
finger_ID = int
nik_kary = varchar
nama_kary = varchar
time = datetime
type = varchar


Regards,

Octo
Oct 6 '10 #7

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

Similar topics

7
43639
by: Barry Young | last post by:
I am using Access to create a SQL query. It creates an Inner Join Query. I cut and paste the query into PL-SQL. When I try to execute the query I get an error. ORA 933 SQL command not properly...
5
4020
by: jason.evans | last post by:
Hi there. I am having an intrigueing problem. I have a query which left joins another query to itself twice. The original query is derived from a linked table in SQLServer 2000. When I run...
4
23867
by: Nathan | last post by:
I have an application that uses an Access database to gather information on students' test scores. In the database there are three tables which are joined by one- to-many relationships: ...
6
9283
by: dmonroe | last post by:
hi group -- Im having a nested inner join problem with an Access SQl statement/Query design. Im running the query from ASP and not usng the access interface at all. Here's the tables: ...
52
6270
by: MP | last post by:
Hi trying to begin to learn database using vb6, ado/adox, mdb format, sql (not using access...just mdb format via ado) i need to group the values of multiple fields - get their possible...
7
2552
by: Christian Muenscher | last post by:
Dear group! The following statement gives me a resultset containing two columns containing a PersonID: SELECT * FROM A LEFT JOIN B ON A.PersonID=B.PersonID UNION SELECT * FROM A
3
2350
by: chaitanya02 | last post by:
I have problem joining four tables using Inner Join in ACCESS DB, I want to join 4 tables: 1, 2, 3 , 4 ....and query data in all these to see, i get a right url associated. sql1-account id,...
12
13156
by: Chamnap | last post by:
Hello, everyone I have one question about the standard join and inner join, which one is faster and more reliable? Can you recommend me to use? Please, explain me... Thanks Chamnap
14
2478
by: cjakeman | last post by:
Hi, Solved a little mystery yesterday when I built a form that combined 2 tables with a 1:M relationship and relational integrity. All the correct data was visible on the form but, if I tried to...
11
19938
by: YZXIA | last post by:
Is there any difference between explicit inner join and implicit inner join Example of an explicit inner join: SELECT * FROM employee INNER JOIN department ON employee.DepartmentID =...
0
7220
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
7105
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
7308
Oralloy
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,...
0
7371
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...
1
7023
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...
0
7479
tracyyun
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...
0
5617
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
3188
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...
0
3178
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.