Set GRID.DataSource = REC
End Sub
that is my code but it wont work. the error is : the rowset is not bookmarkable. pls send me the correct code. thanks a lot.In visual basic 6, how can u bind a datagrid control to the ms access database usng manual coding adodb?
This is an unbound method. It works for me. Hope this helps you too.
Dim Mycon As New ADODB.Connection
Dim M1 As New ADODB.Recordset
Dim S1 As String
S1 = ';Provider=Microsoft.Jet.OLEDB.4.0;'; %26amp; _
';Data Source='; %26amp; _
App.Path %26amp; ';A.mdb';
Mycon.Open S1
M1.Open ';select * from B';, Mycon, adOpenDynamic, adLockOptimistic
Dim c As Integer
Dim r As Integer
Dim col_wid() As Single
Dim field_wid As Single
' Use one fixed row and no fixed columns.
MSFlexGrid1.Rows = 2
MSFlexGrid1.FixedRows = 1
MSFlexGrid1.FixedCols = 0
' Display column headers.
MSFlexGrid1.Rows = 1
MSFlexGrid1.Cols = M1.Fields.Count
ReDim col_wid(0 To M1.Fields.Count - 1)
For c = 0 To M1.Fields.Count - 1
MSFlexGrid1.TextMatrix(0, c) = M1.Fields(c).Name
col_wid(c) = TextWidth(M1.Fields(c).Name)
Next c
' Display the values for each row.
r = 1
Do While Not M1.EOF
MSFlexGrid1.Rows = MSFlexGrid1.Rows + 1
For c = 0 To M1.Fields.Count - 1
MSFlexGrid1.TextMatrix(r, c) = _
M1.Fields(c).Value
' See how big the value is.
field_wid = TextWidth(M1.Fields(c).Value)
If col_wid(c) %26lt; field_wid Then col_wid(c) = _
field_wid
Next c
M1.MoveNext
r = r + 1
Loop
' Set the column widths.
For c = 0 To MSFlexGrid1.Cols - 1
MSFlexGrid1.ColWidth(c) = col_wid(c) + 240
Next c
' Close the recordset and connection.
M1.Close
Mycon.CloseIn visual basic 6, how can u bind a datagrid control to the ms access database usng manual coding adodb?
hello!......he asked for a data grid control and not a flex grid control you DUH!
Report Abuse
No comments:
Post a Comment