Microsoft KB Archive/171952: Difference between revisions

From BetaArchive Wiki
m (Text replacement - "<" to "<")
m (Text replacement - """ to """)
 
(One intermediate revision by the same user not shown)
Line 78: Line 78:
<ol>
<ol>
<li>Start Visual Basic and create a Standard EXE. Form1 is added by default.</li>
<li>Start Visual Basic and create a Standard EXE. Form1 is added by default.</li>
<li>Bring up the Components dialog window by selecting the menu item Project/Components. Select &quot;Microsoft FlexGrid Control 5.0&quot; and click OK.</li>
<li>Bring up the Components dialog window by selecting the menu item Project/Components. Select "Microsoft FlexGrid Control 5.0" and click OK.</li>
<li>Add a MSFlexGrid control (MSFlexGrid1) and a Data control (Data1) to Form1.</li>
<li>Add a MSFlexGrid control (MSFlexGrid1) and a Data control (Data1) to Form1.</li>
<li>Set the DefaultType property of Data1 to UseODBC.</li>
<li>Set the DefaultType property of Data1 to UseODBC.</li>
Line 84: Line 84:
<li><p>Add the following lines of code to the Load event of Form1:<br />
<li><p>Add the following lines of code to the Load event of Form1:<br />
<br />
<br />
'''Note''' You must change Username=<username&gt; and PWD=<strong password&gt; to the correct values before you run this code. Make sure that Username has the appropriate permissions to perform this operation on the database.</p>
'''Note''' You must change Username=<username> and PWD=<strong password> to the correct values before you run this code. Make sure that Username has the appropriate permissions to perform this operation on the database.</p>
<pre class="codesample">      'Replace MY_SERVER with an appropriate SQL pubs database DSN.
<pre class="codesample">      'Replace MY_SERVER with an appropriate SQL pubs database DSN.
       Data1.Connect = &quot;ODBC;DSN=MY_SERVER;Username=<username&gt;;PWD=<strong password&gt;;&quot;
       Data1.Connect = "ODBC;DSN=MY_SERVER;Username=<username>;PWD=<strong password>;"
       Data1.RecordSource = &quot;SELECT * FROM TITLES&quot;
       Data1.RecordSource = "SELECT * FROM TITLES"
       Data1.Refresh
       Data1.Refresh



Latest revision as of 10:05, 21 July 2020

Article ID: 171952

Article Last Modified on 3/2/2005



APPLIES TO

  • Microsoft Visual Basic 5.0 Learning Edition
  • Microsoft Visual Basic 5.0 Professional Edition
  • Microsoft Visual Basic 5.0 Enterprise Edition



This article was previously published under Q171952

SYMPTOMS

The MSFlexGrid control does not return all rows when bound to a Data control whose DefaultType is UseODBC.

RESOLUTION

All of the following are possible workarounds:

  • Change the DefaultType property of the Data control to UseJet.
  • Replace the Data control with the Remote Data Control.
  • Replace the MSFlexGrid control with the DBGrid control.


STATUS

Microsoft is researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

The DefaultType property of the Data control is new to Visual Basic 5.0. It determines what type of data source (Jet or ODBCDirect) to use when creating a Recordset.

Steps to Reproduce Behavior

  1. Start Visual Basic and create a Standard EXE. Form1 is added by default.
  2. Bring up the Components dialog window by selecting the menu item Project/Components. Select "Microsoft FlexGrid Control 5.0" and click OK.
  3. Add a MSFlexGrid control (MSFlexGrid1) and a Data control (Data1) to Form1.
  4. Set the DefaultType property of Data1 to UseODBC.
  5. Set the DataSource property of MSFlexGrid1 to Data1.
  6. Add the following lines of code to the Load event of Form1:

    Note You must change Username=<username> and PWD= to the correct values before you run this code. Make sure that Username has the appropriate permissions to perform this operation on the database.

          'Replace MY_SERVER with an appropriate SQL pubs database DSN.
          Data1.Connect = "ODBC;DSN=MY_SERVER;Username=<username>;PWD=<strong password>;"
          Data1.RecordSource = "SELECT * FROM TITLES"
          Data1.Refresh
    
          'Number of rows in the Recordset.
          MsgBox Data1.Recordset.RecordCount
    
          'Number of rows in MSFlexGrid1 excluding the title row.
          MsgBox MSFlexGrid1.Rows - 1
    
                            
  7. Press the F5 key to run the project and note the discrepancy in the numbers displayed.



Additional query words: kbVBp500 kbVBp kbWinOS98 kbDSupport kbdse kbNoKeyWord

Keywords: kbprb KB171952