|
-
Nov 21st, 2004, 04:33 AM
#1
Thread Starter
Fanatic Member
Ammending code to show on data bound grid
Normally when i open an ado code i do it as the code is below.
I would like to know how to ammend the code so it shows it in a databound grid???????????????
I know it has something to do with datasource property but cannot work out the correct place to place it and what to call it with.
I no longer want to show it in a textbox.
VB Code:
Private Sub Form_Load()
Set r = GetData
textbox1.text = r![InvoiceNo]
End sub
Public Function GetData() As ADODB.Recordset
On Error Resume Next
Dim strsql As String
Dim r As ADODB.Recordset
Dim c As ADODB.Connection
Set c = New ADODB.Connection
c.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False; Data Source=.\home.mdb;"
c.Open
strsql = "SELECT * from Invoice"
Set r = New ADODB.Recordset
r.Open strsql, c, adOpenDynamic, adLockPessimistic
Set GetData = r
End Function
Last edited by snipered; Nov 21st, 2004 at 05:51 PM.
-
Nov 21st, 2004, 11:31 AM
#2
Just set the datasource to the recordset. I don't use bound mode but I think you need to use a Client Side cursor on the recordset.
VB Code:
Private Sub Form_Load()
Set DataGrid1.DataSource = GetData
End sub
Last edited by brucevde; Nov 21st, 2004 at 11:37 AM.
-
Nov 21st, 2004, 05:51 PM
#3
Thread Starter
Fanatic Member
Thanx for that, it didn't work with a data bound grid, kept bringing up errors so i tried it with a ms flex grid and it did the job.
-
Nov 21st, 2004, 06:09 PM
#4
you know, I was going to suggest that last night, but wanted to learn a bit more, so I waited for replies.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|