[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.2

ADO Problem with unbound form in Access 2007

Asked by wsturdev in .NET, Microsoft Access Database, ActiveX

Tags: Access, 2007, ADO, Unbound Form

I asked a question about this topic recently under a different title (http://www.experts-exchange.com/Microsoft/Development/MS_Access/Access_Coding-Macros/Q_23212306.html), got a quick response, but have since not seen any activity on the question.  I posted a followup, but have not gotten any further responses, so I am reposting it here with more information:

Can anyone tell me what is causing the error described below?

The attached code uses ActiveX Data Object, ADO, and is working in Microsoft Access 2003, but fails to work some of the time in Access 2007.

A function (DataSelect) sends a query to the SQL server (2005), using cursortype property adOpenForwardOnly and LockType property of adLockReadOnly.

A successful result of 1 expected record is returned to an ADODB recordset. The connection is set to nothing, however, resulting in a disconnected ADO recordset.

The disconnected ADO recordset is then passed to a clone function (CloseRS).  The passed ADO recordset is saved to disk using ADO's stream object in a persistent recordset in XML format.

The stream recordset is read into a string (str = oStream.ReadText) and searched for various values, which are replaced with other values (see the attached code - lines 67 through 75).

The stream recordset is then replaced by the str, which is then set to a new ADODB recordset and returned to the DataSelect function.

The DataSelect function then returns the ADODB recordset to the calling routine, and that is where the error occurs.

So far, I have determined that this process does not work for some Forms' Control Sources, but does work for others, and seems to work on combo boxes, text boxes, etc.  The problem does NOT occur for ALL forms.  I have not been able to find a pattern in the failures based on the types of data being retrieved, nor have I found anything consistent between the forms where this fails.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
Public Function DataSelect(strQuery As String, Optional params As Collection, Optional isSQLQuery As Boolean, Optional replaceAsIs As Boolean) As ADODB.Recordset
    On Error GoTo Err_DS
    Dim count As Integer
    If IsNull(isSQLQuery) Or Not isSQLQuery Then strQuery = CodeDb.QueryDefs(strQuery).SQL
    
    If m_adoCnn.State <> adStateOpen Then
        OpenConnection g_strConnectionString
    End If
    
        Dim adoCmd As New ADODB.Command
        Dim adors As New ADODB.Recordset
        If Not (params Is Nothing) Then
            If IsNull(replaceAsIs) Or Not replaceAsIs Then
                For count = 1 To params.count
                   strQuery = Replace$(strQuery, params.Item(count).Name, "'" & params.Item(count).value & "'", , , vbTextCompare)
                Next count
            Else
                For count = 1 To params.count
                   strQuery = Replace$(strQuery, params.Item(count).Name, params.Item(count).value, , , vbTextCompare)
                Next count
            End If
        End If
        Debug.Print strQuery
        
        Set adoCmd.ActiveConnection = m_adoCnn
        adoCmd.CommandType = adCmdText
        adoCmd.CommandText = strQuery
        adors.Open adoCmd, , adOpenForwardOnly, adLockReadOnly
        Set adors.ActiveConnection = Nothing
        
        Dim rs As ADODB.Recordset
        Set rs = CloneRS(adors)
        Set DataSelect = rs
        
        adors.Close
        Set adors = Nothing
        Set adoCmd = Nothing
    
Exit_DS:
    Exit Function
 
Err_DS:
    HandleSecurityProblem err.Number, err.Description
    MsgBox ("Error in DataSelect" & Chr(13) & "Error # " & str(err.Number) & " was generated by " & err.Source & Chr(13) & err.Description)
    Set DataSelect = Null
    Resume Exit_DS
End Function
 
 
'-------------------------------------------------------------------------
Public Function CloneRS(ByVal oRs As ADODB.Recordset) As ADODB.Recordset
    Dim oStream As ADODB.Stream
    Dim oRsClone As ADODB.Recordset
    Dim str As String
    
    Dim intIdIndex As Integer
    Dim intAttrEndIndex As Integer
    Dim intAttrWriteIndex As Integer
     
    'save the recordset to the stream object
    Set oStream = New ADODB.Stream
    oRs.Save oStream, adPersistXML
    
    str = oStream.ReadText
    
     
     intIdIndex = InStr(1, str, "s:AttributeType name='ID'", vbTextCompare)
     
     If (intIdIndex > 0) Then
         intAttrEndIndex = InStr(intIdIndex, str, ">", vbTextCompare)
         intAttrWriteIndex = InStr(intIdIndex, str, "rs:writeunknown='true'", vbTextCompare)
         If ((intAttrEndIndex > intAttrWriteIndex) And (intAttrWriteIndex > intIdIndex)) Then
            str = Replace$(oStream.ReadText, "rs:writeunknown='true'", "", , 1, vbTextCompare)
        End If
        str = Replace$(str, "s:AttributeType name='id'", "s:AttributeType name='id' rs:writeunknown='true'", , , vbTextCompare)
    End If
    
    oStream.position = 0
    oStream.WriteText str
    oStream.position = 0
    
    'and now open the stream object into a new recordset
    Set oRsClone = New ADODB.Recordset
    oRsClone.Open oStream, , adOpenKeyset, adLockPessimistic
    
    'return the cloned recordset
    Set CloneRS = oRsClone
    'release the reference
    oStream.Close
    Set oStream = Nothing
    Set oRsClone = Nothing
End Function
[+][-]07/14/08 09:29 AM, ID: 21999594Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: .NET, Microsoft Access Database, ActiveX
Tags: Access, 2007, ADO, Unbound Form
Sign Up Now!
Solution Provided By: LPurvis
Participating Experts: 2
Solution Grade: A
 
[+][-]03/13/08 05:08 AM, ID: 21115261Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/13/08 07:57 AM, ID: 21116830Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/13/08 08:07 AM, ID: 21116932Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/13/08 08:46 AM, ID: 21117404Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/13/08 08:55 AM, ID: 21117516Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/13/08 08:59 AM, ID: 21117567Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/13/08 09:00 AM, ID: 21117571Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/13/08 09:15 AM, ID: 21117739Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/13/08 09:31 AM, ID: 21117946Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/13/08 10:50 AM, ID: 21118828Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/13/08 11:34 AM, ID: 21119269Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/14/08 07:32 PM, ID: 21131118Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/16/08 01:29 PM, ID: 21138324Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/17/08 05:19 AM, ID: 21141453Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/17/08 05:22 AM, ID: 21141474Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/17/08 05:29 AM, ID: 21141506Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/17/08 05:57 AM, ID: 21141680Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/17/08 01:01 PM, ID: 21145583Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/17/08 01:55 PM, ID: 21146038Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/17/08 04:53 PM, ID: 21147445Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/17/08 06:49 PM, ID: 21147863Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/18/08 06:24 AM, ID: 21150675Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/19/08 06:33 AM, ID: 21161312Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/28/08 06:03 AM, ID: 21229939Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/28/08 08:53 AM, ID: 21231504Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06/28/08 05:38 AM, ID: 21890678Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]06/29/08 06:39 AM, ID: 21893922Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06/30/08 04:52 AM, ID: 21898255Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/10/08 11:28 AM, ID: 21976150Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]07/14/08 09:43 AM, ID: 21999700Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/14/08 09:49 AM, ID: 21999759Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/14/08 10:08 AM, ID: 21999961Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/14/08 10:18 AM, ID: 22000075Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/14/08 05:29 PM, ID: 22003264Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]07/14/08 06:16 PM, ID: 22003495Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/14/08 07:54 PM, ID: 22003833Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-92 / EE_QW_EXPERT_20070906