Something not .NET related, regarding VB6.
Here is some strange behaviour:
Create a new .EXE project with the following References and Components:
References : Microsoft DAO 3.51 Object Library Components : Microsoft Data Bound Grid Control 5.0 (SP3)
Add a DBGrid to your form with it's DataSource set to datQuery (Data).
Add a textbox and a button as well, and put this code in it:
[vb] Option Explicit
Private Sub cmdExecute_Click() Call LoadTable(txtquery.Text) End Sub
Private Sub LoadTable(strQuery As String) Dim Db As Database, Rs As Recordset
Set Db = DBEngine.Workspaces(0).OpenDatabase(dbPath) Set Rs = Db.OpenRecordset(strQuery) Rs.MoveLast Rs.MoveFirst Set datQuery.Recordset = Rs
Me.Caption = "Query - Colums: " & Rs.Fields.Count & " - # Records: " & Rs.RecordCount End Sub [/vb]
Run your code, and this is what it should look like:
Now, go to the Custom properties of the DBGrid, to the Layout tab and uncheck 'AllowSizing'.
Run your program again, and now your DBGrid will indicate there are results, but there will be no text, like this:
Why is it doing this? I really have no idea. But the best part is, when you check the AllowSizing property again, it isn't back to normal. It stays broken.
This 'bug' (don't know if it's a bug) was encountered some days ago, I reproduced it this afternoon, and now I installed VS6 SP6, but the bug remains.
If anyone wants a project which has the bug in it, I uploaded something small (30Kb) that got destroyed by this.
Anyone who has encountered this as well? And perhaps has an explanation of why it's doing this.
Update: Just when I posted this and looked at my post again, I noticed something, the second screenshot only had 2 columns, so I realized it did fetch the records, but didn't knew where to display the data. And when you right click and choose 'Clear Fields' it works again. But the AllowSizing is automatically checked on again. To add some value to this post, maybe anyone knows how to uncheck AllowSizing without the grid resetting it's own columns?