|
-
March 18th, 2010, 05:26 PM
#1
Ado controller SQL
Hi I am doing a college project on VB6 and I am having problems with using an adocontroller to take data from two different tables from a database which are linked together. I have tried this SQL query under the ADO controller recordsource but it dosent seem to work, help please.
SELECT Event.eventID, Event.performers, Event.event_date, Event.start_time, Event.finish_time, Event.genre, Event.VenueID, Venue.venueID, Venue.venue_name, Venue.city, Venue.seat_number
FROM Venue INNER JOIN Event ON Venue.venueID = Event.VenueID
WHERE (([where Venue].[venueID]=[Event].[VenueID]));
-
March 18th, 2010, 05:39 PM
#2
Re: Ado controller SQL
Take a look at my sample here.
To solve your problem, you need 2 connection strings.
-
March 18th, 2010, 05:51 PM
#3
Re: Ado controller SQL
thanks for the help but I am still a little confused?
-
March 18th, 2010, 06:34 PM
#4
Re: Ado controller SQL
Download the program, then read the article.
Then, install the program, and test it. Go back and read thru the article and follow along. Add breakpoints, to see WHAT happens, and WHEN it happens.
Inspect variables.
SQL isn't the same as VB6...
-
March 21st, 2010, 05:48 PM
#5
Re: Ado controller SQL
I still havent got it to work and by the way how can you get 2 connection strings
-
March 21st, 2010, 06:36 PM
#6
Re: Ado controller SQL
I am not sure what you mean when you say ADOControler. ?? Do you mean the ADO Control? If so I never saw a need to use it better to code it yourself.
That said ADO code allows you to join 2 or more tables and return data without a problem, only one connection is requried.
Also the where clause you have is not needed as the inner join takes care of matching the records in this case returning only records where the venueid exists in both tables.
-
March 21st, 2010, 06:43 PM
#7
Re: Ado controller SQL
A quick sample from a project I did using MYsql as a backend
Code:
Dim Cn As New Connection
Cn.CursorLocation = adUseClient
Cn.Open ConnectionString
Dim RS As New Recordset
RS.Open "select PackQty from FGInventory inner Join Products on Products.idPartSku=FGInventory.Products_idPartSku where FGInventory.idPackSN=" & MatSN, Cn, adOpenDynamic, adLockOptimistic
If RS.RecordCount > 0 Then
MatQty = RS(0)
RS.Close
Else
'not found
RS.Close
End If
Must include a reference to the ADO libary.
ConnectionString is a variable that contains the actual connection string for the database in question
Last edited by DataMiser; March 21st, 2010 at 06:45 PM.
-
March 22nd, 2010, 09:44 PM
#8
Re: Ado controller SQL
This part looks weird and You shouldn't need it.
WHERE (([where Venue].[venueID]=[Event].[VenueID]));
-
March 22nd, 2010, 10:04 PM
#9
Re: Ado controller SQL
I did not notice the [where venue] in there.
Is that actually the name of a table in the database?
If not then that is a problem for sure.
-
March 23rd, 2010, 06:09 PM
#10
Re: Ado controller SQL
yup thanks for the replies Venue and Event are the names of the tables and I have tried to run the program without the line WHERE (([where Venue].[venueID]=[Event].[VenueID]));
but its linked but not properley but someone has suggested making an SQL query within the form rather than in the recordsource property of the ADO control, which i will try
-
March 23rd, 2010, 07:27 PM
#11
Re: Ado controller SQL
I am not sure but could be that Event is a reserved word
This may be a problem
Code:
FROM Venue INNER JOIN Event
In some areas you are using the [] around the table name. I would suggest you do that on the portion above as well.
-
March 23rd, 2010, 07:30 PM
#12
Re: Ado controller SQL
Try it like this and see what happens
Code:
SELECT [Event].eventID, [Event].performers, [Event].event_date, [Event].start_time, [Event].finish_time, [Event].genre, [Event].VenueID, Venue.venueID, Venue.venue_name, Venue.city, Venue.seat_number
FROM [Event] INNER JOIN [Venue] ON [Venue].venueID = [Event].VenueID
-
March 23rd, 2010, 07:56 PM
#13
Re: Ado controller SQL
Change the name of the field(s). Besides being reserved, it doesn't make a lot of sense
-
April 23rd, 2010, 11:09 AM
#14
Re: Ado controller SQL
Another solution that makes me feel comfortable using two or more tables.
Make a view, it will integrate your database, it's very simple and fast performance unlike inner join technique.
-----------
Mike
http://visualbasic-source-code.com/
-
April 23rd, 2010, 11:16 AM
#15
Re: Ado controller SQL
Here's the sample View in MS Access Database
'---Code
SELECT CATrans.RecordNo, CATrans.EmployeeNo, view_employeeInfo.Name, CATrans.DateCA, CATrans.Amount, CATrans.Reason
FROM CATrans LEFT JOIN view_employeeInfo ON CATrans.EmployeeNo = view_employeeInfo.EmployeeNo;
Please find the picture file attached.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|