|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
remove all dbgrid columns
I am trying to clear all the columns on the grid.
ive tried the following Code:
While dbGrid.Columns.Count <> 0
dbGrid.Columns.Remove 0
Wend
but i get invalid column index on the last column it tries to remove
__________________
Tewl |
|
#2
|
||||
|
||||
|
I do not get the same error.
Have you placed a breakpoint and stepped through to see what is going on and does it remove the last column? |
|
#3
|
||||
|
||||
|
still same thing, i added a datagrid to a form an did
Code:
Private Sub Form_Load()
While DataGrid1.Columns.Count <> 0
DataGrid1.Columns.Remove 0
Wend
End Sub
an i get the error still. It doesnt remove the last column if i do DataGrid1.Columns.Remove 0 when there is only one column it will error |
|
#4
|
||||
|
||||
|
hm well nevermind i just did it like this
Code:
dbGrid.Visible = False
While dbGrid.Columns.Count > 1
dbGrid.Columns.Remove 0
Wend
Dim TblFields As Integer
TblFields = MyRset.Fields.Count
If TblFields > 0 Then
TblFields = TblFields - 1
For t = 0 To TblFields
dbGrid.Columns.Add(t).Caption = MyRset.Fields(t).Name
Next t
End If
dbGrid.Columns.Remove dbGrid.Columns.Count - 1
dbGrid.Visible = True
|
|
#5
|
||||
|
||||
|
just out of curiosity...
what service pack are you running? have you tried it with another grid control? (ie truedbgrid6|7) . . and of course I have to ask...are you a bama or auburn fan? (fellow bama native) ![]() |
|
#6
|
||||
|
||||
|
Micorosoft DataGrid Control 6.0 (SP5) (OLEDB)
no I haven't really tried any other. I was using flexgrid but I dont like the look of it. hm Bama prolly just cause my parents are auburn fans tho I never could agree with them |
|
#7
|
||||
|
||||
|
I'm working on a program to help me view an edit my mysql databases. I'm don't know much about database programs I'm just trying to pick up as much as I can as I go. I found some examples but they all use the .mdb files as datasource an I was wondering is there another way I can list the data in the datagrid.
I know Recordset.getString as the data an each row is divided by a vbcr but thats about it |
|
#8
|
||||
|
||||
|
are you manually going through the resultset and entering the data into the grid or are you just binding the grid to the resultset?
Let me show you one of my little database viewers that I made a while back. It doesn't deal with mysql, it is meant to deal with a db2 database, but the concept should be the same once you have connected to the database. Code:
'opens an ado read only recordset
Public Function OpenRSro(sql As String) As ADODB.Recordset
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
rst.Open sql, cn, adOpenForwardOnly
Set OpenRSro = rst
End Function
Private Sub fillGrid(ByVal sql As String)
On Error GoTo errInvalidStatement
Set DataGrid1.DataSource = OpenRSro(sql)
Exit Sub
errInvalidStatement:
MsgBox "An error occured while attempting to execute the query:" & vbCrLf _
& sql & vbCrLf & "Error #: " & Err.Number & vbCrLf & "Error Desc: " & _
Err.Description
On Error GoTo 0
End Sub
This is designed to use an ado connection and just call the fillGrid function with a correct sql statement. |
|
#9
|
||||
|
||||
|
any ideas why i get this error
Code:
An error occured while attempting to execute the query: select * from members Error #: 7004 Error Desc: The rowset is not bookmarkable. |
|
#10
|
||||
|
||||
|
try adding the database name before it.
i.e. select * from some_db.members |
|
#11
|
||||
|
||||
|
Last edited by Tewl : March 19th, 2003 at 06:33 AM. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > remove all dbgrid columns |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|