Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 17th, 2003, 07:13 PM
Tewl's Avatar
Tewl Tewl is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Posts: 47 Tewl User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 57 m 13 sec
Reputation Power: 7
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

Reply With Quote
  #2  
Old March 17th, 2003, 10:28 PM
Onslaught's Avatar
Onslaught Onslaught is offline
/(bb|[^b]{2})/
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2001
Location: Somewhere in the great unknown
Posts: 4,840 Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 2 Days 36 m 16 sec
Reputation Power: 88
Send a message via ICQ to Onslaught
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?

Reply With Quote
  #3  
Old March 18th, 2003, 01:08 AM
Tewl's Avatar
Tewl Tewl is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Posts: 47 Tewl User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 57 m 13 sec
Reputation Power: 7
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

Reply With Quote
  #4  
Old March 18th, 2003, 01:20 AM
Tewl's Avatar
Tewl Tewl is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Posts: 47 Tewl User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 57 m 13 sec
Reputation Power: 7
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

Reply With Quote
  #5  
Old March 18th, 2003, 08:03 AM
Onslaught's Avatar
Onslaught Onslaught is offline
/(bb|[^b]{2})/
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2001
Location: Somewhere in the great unknown
Posts: 4,840 Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 2 Days 36 m 16 sec
Reputation Power: 88
Send a message via ICQ to Onslaught
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)

Reply With Quote
  #6  
Old March 18th, 2003, 01:51 PM
Tewl's Avatar
Tewl Tewl is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Posts: 47 Tewl User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 57 m 13 sec
Reputation Power: 7
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

Reply With Quote
  #7  
Old March 18th, 2003, 02:08 PM
Tewl's Avatar
Tewl Tewl is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Posts: 47 Tewl User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 57 m 13 sec
Reputation Power: 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

Reply With Quote
  #8  
Old March 18th, 2003, 02:22 PM
Onslaught's Avatar
Onslaught Onslaught is offline
/(bb|[^b]{2})/
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2001
Location: Somewhere in the great unknown
Posts: 4,840 Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 2 Days 36 m 16 sec
Reputation Power: 88
Send a message via ICQ to Onslaught
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
The datagrid is an ado data grid.
This is designed to use an ado connection and just call the fillGrid function with a correct sql statement.

Reply With Quote
  #9  
Old March 18th, 2003, 04:02 PM
Tewl's Avatar
Tewl Tewl is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Posts: 47 Tewl User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 57 m 13 sec
Reputation Power: 7
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.

Reply With Quote
  #10  
Old March 18th, 2003, 04:24 PM
Onslaught's Avatar
Onslaught Onslaught is offline
/(bb|[^b]{2})/
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2001
Location: Somewhere in the great unknown
Posts: 4,840 Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 2 Days 36 m 16 sec
Reputation Power: 88
Send a message via ICQ to Onslaught
try adding the database name before it.
i.e.
select * from some_db.members

Reply With Quote
  #11  
Old March 18th, 2003, 05:03 PM
Tewl's Avatar
Tewl Tewl is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Posts: 47 Tewl User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 57 m 13 sec
Reputation Power: 7
switched grids an works fine now :-)

MySQL Client

Last edited by Tewl : March 19th, 2003 at 06:33 AM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > remove all dbgrid columns


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |