Advertisement

03.11.2008 at 09:34AM PDT, ID: 23232337
[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: , , ,

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.Start Free Trial
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
[+][-]03.13.2008 at 05:08AM PDT, ID: 21115261

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.13.2008 at 07:57AM PDT, ID: 21116830

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 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.13.2008 at 08:07AM PDT, ID: 21116932

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.13.2008 at 08:46AM PDT, ID: 21117404

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.13.2008 at 08:55AM PDT, ID: 21117516

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.13.2008 at 08:59AM PDT, ID: 21117567

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 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.13.2008 at 09:00AM PDT, ID: 21117571

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.13.2008 at 09:15AM PDT, ID: 21117739

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 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.13.2008 at 09:31AM PDT, ID: 21117946

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 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.13.2008 at 10:50AM PDT, ID: 21118828

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.13.2008 at 11:34AM PDT, ID: 21119269

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.14.2008 at 07:32PM PDT, ID: 21131118

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 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.16.2008 at 01:29PM PDT, ID: 21138324

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.17.2008 at 05:19AM PDT, ID: 21141453

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 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.17.2008 at 05:22AM PDT, ID: 21141474

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.17.2008 at 05:29AM PDT, ID: 21141506

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 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.17.2008 at 05:57AM PDT, ID: 21141680

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.17.2008 at 01:01PM PDT, ID: 21145583

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 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.17.2008 at 01:55PM PDT, ID: 21146038

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 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.17.2008 at 04:53PM PDT, ID: 21147445

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.17.2008 at 06:49PM PDT, ID: 21147863

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 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.18.2008 at 06:24AM PDT, ID: 21150675

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 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.19.2008 at 06:33AM PDT, ID: 21161312

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 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.28.2008 at 06:03AM PDT, ID: 21229939

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 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.28.2008 at 08:53AM PDT, ID: 21231504

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 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.28.2008 at 05:38AM PDT, ID: 21890678

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 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]06.29.2008 at 06:39AM PDT, ID: 21893922

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 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.30.2008 at 04:52AM PDT, ID: 21898255

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.10.2008 at 11:28AM PDT, ID: 21976150

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 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]07.14.2008 at 09:29AM PDT, ID: 21999594

View this solution now by starting your 7-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
 
 
[+][-]07.14.2008 at 09:43AM PDT, ID: 21999700

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.14.2008 at 09:49AM PDT, ID: 21999759

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.14.2008 at 10:08AM PDT, ID: 21999961

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 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.14.2008 at 10:18AM PDT, ID: 22000075

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.14.2008 at 05:29PM PDT, ID: 22003264

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 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]07.14.2008 at 06:16PM PDT, ID: 22003495

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 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.14.2008 at 07:54PM PDT, ID: 22003833

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 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_EXPERT_20070906