Binding Data to Datagrid

Adrienne
04-16-2004, 08:34 AM
Hi!
Is it possible to bind data from a recordset to a datagrid,like you can do with text boxes
for example, txtID = rs!ID

Thanks for your help!
a ;)

Shurik12
04-16-2004, 08:56 AM
Hi,

Set DataGrid1.DataSource=rs

Shurik.

Adrienne
04-16-2004, 09:05 AM
Thanks!!
I tried that and got an error,I think problem is the fact that there are a lot of null values in the database i am referencing.I know how to fix this problem for text boxes but not data grids any ideas??

Thanks again 4 ur help
a
:D

Shurik12
04-16-2004, 09:10 AM
if the recordest is opened succesfully there should not be any problem with displaying it in the datagrid.
You mentioned an error, what is the error description saying?

Shurik.

Adrienne
04-16-2004, 09:17 AM
Thanks

Its pointing to the datasouce and says the method or data member is not found

The recordset is working perfectly for adding the same data to text boxes on the same form

Shurik12
04-16-2004, 09:28 AM
Could you show the code including how you are opening your recordset.

Adrienne
04-16-2004, 09:32 AM
yup sure,thanks

Dim conn As New ADODB.Connection

Dim rs As New ADODB.Recordset


Private Sub Form_Load()
Dim ConnStr As String


ConnStr = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source= H:\x.mdb; JET OLEDB:"
conn.ConnectionString = ConnStr

'Open the connection
conn.Open
'Print the fact that the connection has been successful to the screen
Debug.Print "Connection Object Created"

rs.Open "SELECT * FROM ModelDescription", conn, adOpenDynamic, adLockOptimistic

LoadData
End Sub

Public Sub LoadData()

DataGrid1.DataSource = rs
Text1 = rs!x
Text2 = rs!x

End Sub

Shurik12
04-16-2004, 09:37 AM
Set DataGrid1.DataSource = rs

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum