Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datagrid not showing data

Status
Not open for further replies.

dagger71

IS-IT--Management
Joined
Sep 3, 2003
Messages
1
Location
NO
I have a datagrid problem. It is my first time working with ADO. This is supposed to be an easy app. I have a text box to input a number. The datagrid is supposed to display the search result. I have a form, with a text box, a search button and a datagrid.

I have the following code on the click event:
--------------
Private Sub cmdSearch_Click()
Dim strSQL As String
Dim rsResult As New Recordset
Dim cnDB As New Connection

strSQL = "SELECT Store, Name, Articlename, InStock" _
& "FROM StockItem" _
& "Where ArticleNo = " & txtArticleNo.Text

cnDB.ConnectionString= _
"Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=C:\StockItem.mdb"
cnDB.Open

Set rsResult = Nothing

rsResult.Open strSQL, cnLagerHK, adOpenStatic, adLockOptimistic

Set Datagrid1.DataSource = rsResult

cnDB.Close
End Sub

-------
I know the rsResult is filled with the right result from the query (it showed in a message box). According to the books/articles/code I've read, this should work. There are no error messages. I have tried Clearfields and refresh, but the grid remains empty (standard 2 columns 1 row).
I am using VB 6.0 (SP5) on a Win2K server. I developed the DB in Access 2K.

Hope you can help.

Thanks.
 
Changing the CursorType from adOpenStatic to adOpenDynamic will not change the cursor type different from the original posted code if using a client side cursor.
A Client side cursor is always static, so the cursor type will change to this regardless.

If you do not need batch updating then you do not need the adLockBatchOptimistic either

You may choose to continue using a Server Side cursor with a JET/Access mdb as this is more efficient, unless you need to using certain ADO Client manager methods such as Sort/Filter, or are using disconnected recordsets (what I would recommend if the mdb is on a server). For this you will need to set the RowIdentity property to True under JET if using a datagrid.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top