<?xml version="1.0" encoding="utf-8"?>

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
	<channel>
		<title>DaniWeb IT Discussion Community</title>
		<link>http://www.daniweb.com/forums/</link>
		<description>Tech support, programming, web development, and internet marketing community. Forums to get free computer help and support.</description>
		<language>en-US</language>
		<lastBuildDate>Tue, 22 Dec 2009 17:36:09 GMT</lastBuildDate>
		<generator>vBulletin</generator>
		<ttl>60</ttl>
		<image>
			<url>http://www.daniweb.com/alphaimages/misc/rss.jpg</url>
			<title>DaniWeb IT Discussion Community</title>
			<link>http://www.daniweb.com/forums/</link>
		</image>
		<item>
			<title>VB6 - Query/StoredProc works in Access but not in VB6 - please help!</title>
			<link>http://www.daniweb.com/forums/thread239867.html</link>
			<pubDate>Fri, 20 Nov 2009 00:01:07 GMT</pubDate>
			<description><![CDATA[Hi, 
 
I've got a bit of a problem with an application I am writing at the moment. I know it has to be something small which I'm missing, but I can't figure out what it is. 
 
Basically, I have a Query (or Stored Procedure if you prefer) in an Access2000 database called qryApptList which has one...]]></description>
			<content:encoded><![CDATA[<div>Hi,<br />
<br />
I've got a bit of a problem with an application I am writing at the moment. I know it has to be something small which I'm missing, but I can't figure out what it is.<br />
<br />
Basically, I have a Query (or Stored Procedure if you prefer) in an Access2000 database called qryApptList which has one parameter (DateOfAppt). This parameter is Text (as is the Date field in the database table).<br />
<br />
If I run the query in Access, it prompts for the Date. I enter it in and it returns my results as it should. If I then do the same thing in VB6 using ADODB, it brings back nothing.<br />
<br />
My VB6 code...<br />
 <pre style="margin:20px; line-height:13px">Private m_oConnection As ADODB.Connection<br />
Private m_oCmdGetAppointments As ADODB.Command<br />
<br />
'Open the database connection<br />
Public Sub OpenDatabaseConnection()<br />
&nbsp; &nbsp; On Error GoTo ErrorHandler<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; If Len(m_sDatabasePath) = 0 Then<br />
&nbsp; &nbsp; &nbsp; &nbsp; m_sDatabasePath = m_oParentForm.FileSelection<br />
&nbsp; &nbsp; End If<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; Set m_oConnection = New ADODB.Connection<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; m_oConnection.Open &quot;Provider=Microsoft.Jet.OLEDB.4.0;&quot; &amp; _<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &quot;Data Source=&quot; &amp; m_sDatabasePath<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; If m_oConnection.State &lt;&gt; adStateOpen Then<br />
&nbsp; &nbsp; &nbsp; &nbsp; Set m_oConnection = Nothing<br />
&nbsp; &nbsp; &nbsp; &nbsp; MsgBox &quot;Could not open connection to database&quot;, vbCritical + vbOKOnly, App.Title<br />
&nbsp; &nbsp; &nbsp; &nbsp; Exit Sub<br />
&nbsp; &nbsp; End If<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; Exit Sub<br />
ErrorHandler:<br />
&nbsp; &nbsp; HandleError &quot;clsDatabaseHandler:OpenDatabaseConnection Sub&quot;<br />
End Sub<br />
<br />
<br />
'Method to get the appointments from the database<br />
Public Function GetAppointments(ByVal sDate As String, ByRef oRsAppts As ADODB.Recordset)<br />
&nbsp; &nbsp; On Error GoTo ErrorHandler<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; If m_oCmdGetAppointments Is Nothing Then<br />
&nbsp; &nbsp; &nbsp; &nbsp; Set m_oCmdGetAppointments = New ADODB.Command<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; With m_oCmdGetAppointments<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Set .ActiveConnection = m_oConnection<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .CommandText = &quot;qryApptList&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .CommandType = adCmdStoredProc<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .Parameters.Append .CreateParameter(&quot;DateOfAppt&quot;, adVarChar, adParamInput, 11)<br />
&nbsp; &nbsp; &nbsp; &nbsp; End With<br />
&nbsp; &nbsp; End If<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; m_oCmdGetAppointments.Parameters(&quot;DateOfAppt&quot;) = sDate<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; Set oRsAppts = New ADODB.Recordset<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; oRsAppts.Open m_oCmdGetAppointments, , adOpenStatic, adLockReadOnly<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; Exit Function<br />
ErrorHandler:<br />
&nbsp; &nbsp; HandleError &quot;clsDatabaseHandler:GetAppointments Function&quot;<br />
End Function</pre><br />
All this code runs within a separate class module which is called from a form.<br />
<br />
And if it helps... my SQL query.<br />
 <pre style="margin:20px; line-height:13px">PARAMETERS DateOfAppt Text ( 255 );<br />
SELECT tblAppointments.ApptId, tblAppointments.User, tblAppointments.ApptDate, tblAppointments.ApptTime, tblAppointments.ClientId, tblAppointments.Comments, tblClients.Title, tblClients.FirstName, tblClients.Surname, tblClients.ContactNumber1<br />
FROM tblClients INNER JOIN tblAppointments ON tblClients.ClientId=tblAppointments.ClientId<br />
WHERE tblAppointments.ApptDate=[DateOfAppt];</pre><br />
I have had it working once and I had a recordcount of 1 in the recordset (I only have one record in the table by the way). I haven't knowingly changed anything but now I get 0 records every time.<br />
<br />
Any help would be massively appreciated as I'm tearing out what little hair I have left!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum4.html">Visual Basic 4 / 5 / 6</category>
			<dc:creator>jonifen</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239867.html</guid>
		</item>
	</channel>
</rss>
