467,132 Members | 1,226 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,132 developers. It's quick & easy.

Help passing and binding to a dataset please.

I am using windows forms and vb.net.

My problem is a little complex so please bear with me.

I have written an application that references a .com based API linked to an external
client application.
The API exposes client user interface objects. One of the objects is similar to a grid.

The first part of my application creates a reference to the grid object in the client
application.
Now, I take that object and pass it to a class I have created in a class library that
accepts that object type in its constructor.

My class only has one function and that takes the gridlike object and converts/returns it
as an untyped dataset.

Let me say that the code to this point the code seems to be working just fine. The
returned dataset can be written out as XML and it all looks good.

The problem comes here:

I tried to create a new form class that accepts a dataset in its constructor. I pass it
a dataset that I have returned from the class detailed above.

During the form load, I try to databind to the dataset and I run into an endless loop of
some sort. The grid never appears, the data never bind etc.

I know I am missing something. I thought I might be able to pass datasets around in this
manner but perhaps I cannot. I know I can do work arounds but I am interested in the
answer as to why this doesn't work.
PSEUDO_CODE

//////////////////////////////////////////////////
MAIN APPLICATION
''Has reference to com API of client user interface

Private _MyDataset as dataset

Sub CatchAnEvent()
Dim MyClientInterfaceGridObject
Dim New MyClass(MyClientInterfaceGridObject)
_MyDataset = MyClass.ReturnDatasetFromGridlikeObject
''All is good to here. If I write the xnl out of the dataset it looks fine.

Dim MyNewForm as new form1(_MyDataset)
MyNewForm.show ''Here is where the problem occurs. MyNewForm gets stuck loading

End Sub
//////////////////////////////////////////////////

//////////////////////////////////////////////////
FORM1
''Plain old windows form. I have altered the "New" to accept a dataset
Private _ds as dataset
Public Sub New(byVal ds as dataset)
MyBase.New()
InitializeComponent()
_ds = ds
End Sub
Private Sub FormLoad
'I have tried a number of methods of databinding with two different grids...
'Here is the last one I tried using an MS grid...
datagrid1.setdatabinding(_ds, _dsTables(0).Tablename)
End Sub

///////////////////////////////////////////////////
Any help would be appreciated. I am wondering if I might have to do some serialization to
create something I can bind to when passing an untyped dataset around like this.

Thanks in advance!
Nov 21 '05 #1
  • viewed: 958
Share:
5 Replies
I started doing some additional debugging and it may be that there is a problem loading
forms in the threading model that is in use in my solution, not in the manner I was
passing datasets around with.

Nov 21 '05 #2
Darious,

Any reason that you do not show it to us in the normal way with a standard
datagrid

datagrid1.datasource = ds.tables(0) 'I assume

Cor
Nov 21 '05 #3
Cor:

You have been around here for a million years. Maybe you can help. It seems that my
problem has nothing to do with datasets. It has to do with simple form loading.

If I instantiate and show form1 in the "New" sub of my main application, the form loads
just fine. However, if I try to show it in a different sub (an item event sub) the form
gets hung. If I hoved the mouse on it, there is an hourglass.
The sub I am trying to load it from looks like this:

Private Sub ClientApplication_ItemEvent(Byval X, ByRef Y as itemEvent, ByRef Z as bool)
handles ClientApplication.ItemEvent
''In this sub, I trap an item event and simply try to load the form....
If Y=MyCriteria then
Dim MyForm as form1
MyForm.show
End If
End Sub

The exact same form loads just fine if I dim it and load it when my application class is
instantiated.
If I do it in the manner above, the form hangs on load.

Any idea what is blocking? How might I get around this?

Thanks!
Nov 21 '05 #4
Darius

Private Sub ClientApplication_ItemEvent(Byval X, ByRef Y as itemEvent,
ByRef Z as bool)
handles ClientApplication.ItemEvent
''In this sub, I trap an item event and simply try to load the form....
If Y=MyCriteria then
Dim MyForm as form1
MyForm.show
End If
End Sub

MyForm1 should in my opinion in this statement be nothing and absolute not
work.
(There should be an error be showed)

Cor
Nov 21 '05 #5
Like Cor said, it won't work. myform has not been instantiated to anything
since you only delcared it's type, not an instance of the type. This is
pretty basic so you should be able to figure it out from here.

"Darious Snell" wrote:
I started doing some additional debugging and it may be that there is a problem loading
forms in the threading model that is in use in my solution, not in the manner I was
passing datasets around with.

Nov 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Steven | last post: by
2 posts views Thread by Daniel | last post: by
7 posts views Thread by Richard | last post: by
reply views Thread by Magnus Bergh | last post: by
4 posts views Thread by John Sheppard | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.