Wrox Programmer Forums
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 27th, 2007, 03:27 AM
Registered User
 
Join Date: Feb 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to irisnun
Default datagrid can't show anything

Hi, anybody can help me? I have a problem about datagrid can't show the data. I have try to debug but that have not any error message pop-up. The following code is me create to show the data in datagrid

Dim selectDrssql As String
Dim ds As ADODB.Recordset
Dim cnn As ADODB.Connection

Set cnn = New ADODB.Connection

cnn.Open ("Driver=MySQL ODBC 3.51 Driver; UID=pre;password=pre888;server=localhost;database= preshipment")

selectDrssql = "SELECT * FROM drs WHERE PRESTATUS = 'F'ORDER BY DELDATE,DRSNO"

Set ds = New ADODB.Recordset

With rsDrs
        .ActiveConnection = cnn
        .CursorLocation = adUseClient
        .CursorType = adOpenForwardOnly
        .LockType = adLockReadOnly
        .Source = selectDrssql
        .Open
        .ActiveConnection = Nothing
End With
Set dtgDRS.DataSource = ds

Thank.

 
Old March 14th, 2007, 01:41 PM
Registered User
 
Join Date: Mar 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Everything is all right up until the point where you start the with block. First of all, what is rsDrs? I'm assuming this was meant to be ds. With that assumption, you should have something like this:

With ds
   Set .ActiveConnection = cnn
   .CursorLocation = adUseClient
   .CursorType = adOpenForwardOnly
   .LockType = adOpenForwardOnly
   .Source = selectDrssql
   .Open
   Set .ActiveConnection = Nothing
End With

Set dtgDRS.DataSource = ds ' I'm assuming this is the datagrid?

I'm not sure you want to set the connection to Nothing and if you want to be able to edit the contents of the grid, you'll need to use a different CursorType and LockType. The biggest error I can see is that when you are assigning an object to a property, you need to use Set. In other words Set Something.Property = Object instead of Something.Property = Object.

See if that helps.





Similar Threads
Thread Thread Starter Forum Replies Last Post
The DataGrid does not show data sams ASP.NET 1.0 and 1.1 Professional 16 June 20th, 2007 07:19 AM
show date/time in a datagrid. mehmetned C# 2005 0 March 23rd, 2007 08:43 AM
show date/time in a datagrid. mehmetned ASP.NET 1.0 and 1.1 Basics 0 March 23rd, 2007 08:38 AM
How can i show data in datagrid? Blueman137 ASP.NET 1.0 and 1.1 Basics 0 March 30th, 2004 08:31 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.