Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 23rd, 2003, 05:03 AM
dbeagle dbeagle is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 2 dbeagle User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
VB - Access join statement

I am writing an application with a VB front end and Access back end. I usually code using SQL server and stored procedures, so I’m not sure if this is an Access issue or not. For some reason I cannot get this particular sql statement to run. If I replace it with a statement that does not contain a join it runs fine. I copy the statement and run it in access and it runs there. The error I get is: Method ‘Open’ of object’_Recordset’ failed. Any ideas would be greatly appreciated.

Function SqlGetAgeOfOnset(inIndex As Integer) As ADODB.Recordset

Dim rsFDAge As ADODB.Recordset
Set rsFDAge = New ADODB.Recordset


rsFDAge.ActiveConnection = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=D:\VBProjects\Disease\dr.mdb;"

Dim strSqlStatement As String

'Open the recordset.
strSqlStatement = "SELECT Cross.DiseasecondId, Cross.AgeOfOnsetId, AgeOnset.Description, Cross.Text " & _
"FROM [Cross] INNER JOIN AgeOnset ON Cross.AgeOfOnsetId = AgeOnset.Id " & _
"Where (((Cross.DiseasecondId) = " & inIndex & ")) " & _
"ORDER BY AgeOnset.SortOrder"



rsFDAge.Open strSqlStatement, , adOpenStatic, _
adLockReadOnly, adCmdText

Set SqlGetAgeOfOnset = rsFDAge

End Function

Reply With Quote
  #2  
Old December 23rd, 2003, 09:28 AM
williamcrawley williamcrawley is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: uk
Posts: 91 williamcrawley User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
This has nothing to do with the SQL statement, but is a problem with the way you are trying to open the connection.

Open the connection using an ADODB.Connection, then return the recordset against the connections execute method.

Also with the above code, before you exit the function, you should close rsFDAge

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > VB - Access join statement


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT