Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > General Discussion
  New Posts New Posts RSS Feed - 3 Table MS Access Relational Database.  P
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

3 Table MS Access Relational Database. P

 Post Reply Post Reply
Author
Message
jetski4419 View Drop Down
Newbie
Newbie


Joined: 13 June 2005
Location: United Kingdom
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote jetski4419 Quote  Post ReplyReply Direct Link To This Post Topic: 3 Table MS Access Relational Database. P
    Posted: 13 June 2005 at 3:53pm

I have designed a MS Access Database with three tables: CUSTOMERS, BOOKINGS & HOLIDAYS.

CUSTOMERS has a Primary Key called UCI.

BOOKINGS has a Primary key called [Number]. Two Foreign keys: UCI (link to CUSTOMERS) & Code (link to HOLIDAYS).

HOLIDAYS has a Primary Key called Code.

The Database has one-to-many Relationships with Referential Integrity and checked cascade UPDATE and DELETE (The many relationship for both links being on the BOOKINGS table).

I have designed a GUI using vb.NET (Visual Studio) The connection to the Database is via Microsoft Jet 4.0 OLE DB Provider and I have got the following Datasets to work on both the CUSTOMERS and HOLIDAYS tables: SELECT, INSERT, DELETE, UPDATE records.

 

On coming to the BOOKINGS table (which appears to be an INNER JOIN) I've got the SELECT and DELETE records to work, but I'm having major problems getting the INSERT and UPDATE to work. View the SQL Statements  below:

 

 

 

 

I have now generated a SELECT query by going through the OleDbAdapter process and the Following query was produced and works fine:

"SELECT BOOKINGS.*, CUSTOMERS.UCI AS Expr1, HOLIDAYS.Code AS Expr2 FROM ((BOOKINGS INNER JOIN CUSTOMERS ON BOOKINGS.UCI = CUSTOMERS.UCI) INNER JOIN HOLIDAYS ON BOOKINGS.Code = HOLIDAYS.Code) "

 


I’m problems with the INSERT Statement, the syntax is:

"INSERT INTO BOOKINGS, CUSTOMERS.UCI AS Expr1, HOLIDAYS.Code AS Expr2 FROM ((BOOKINGS INNER JOIN CUSTOMERS ON BOOKINGS.UCI = CUSTOMERS.UCI) INNER JOIN HOLIDAYS ON BOOKINGS.Code = HOLIDAYS.Code )" _
                 & " values('" & txtNumber.Text & "', '" & txtUCI.Text & "','" & txtCode.Text & "','" & txtDate.Text & "','" & txtAdult.Text & "','" & txtChild.Text & "','" & txtDeposit.Text & "','" & txtBalance.Text & "','" & txtCost.Text & "')"

There is no error on submitting the INSERT, but the record is not being saved into the Database.


I am also having problems with the UPDATE Satement, the syntax is:

"UPDATE BOOKINGS SET [Number] = '" & txtNumber.Text _
             & "', " & "UCI = '" & txtUCI.Text _
             & "', " & "Code = '" & txtCode.Text _
             & "', " & "Date = '" & txtDate.Text _
             & "', " & "Adult = ' " & txtAdult.Text _
             & "', " & "Child = ' " & txtChild.Text _
             & "', " & "Deposit = ' " & txtDeposit.Text _
             & "', " & "Balance = ' " & txtBalance.Text _
             & "', " & "Cost = ' " & txtCost.Text _
             & "' WHERE [Number] = '" & txtNumber.Text & "'"

The error for the UPDATE is: 'Syntax error in UPDATE Statement.


I have attached the relevent vb.NET Forms (Not the whole Project) and the Database, I hope somebody can help me. I'm tearing my hair out and I didn't have much to start with anyway

 

Regards jetski4419

2005-06-13_155155_vb.NET_DB_Quest.zip

 

 

jetski4419
Back to Top
sserge View Drop Down
Moderator Group
Moderator Group


Joined: 01 December 2004
Status: Offline
Points: 1297
Post Options Post Options   Thanks (0) Thanks(0)   Quote sserge Quote  Post ReplyReply Direct Link To This Post Posted: 16 June 2005 at 7:07am
Hi,

With your UPDATE query -- set square brackets around each field name, especially around [Date] field, which is also seems to be the reserved word.

--
WBR,
Serge
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.141 seconds.