Problem with Dataser

R

Rado

Hello.
I have one question.
I make form1 and form2.
In form1 I make connection to databasee, make dataadpater, and generate
dataset.
On Form1 I have one Textbox. This textbox I bind with dataset.
And on Form2 I have textbox too, but I wouldn`t make connection, dataadpter,
and generate dataset, I want this textbox bind with dataset in Form1.
Have any idea How can I do it?

I think that I can write this:
****************************************************************************
****
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim frm As Form1

TextBox1.DataBindings.Add("Text0", frm.DataSet11, "moj.meno")

End Sub

****************************************************************************
***************

But probaly is wrong, because VB.NET while compling show error.



Thank You very much for yours answer.
 
D

Dana Coffey

One way is to put your data access code in a class file as a function and
call the function from each form.

hth,
 
G

Greg

Create a Form. Call it something like MyBaseForm. Create a Property in this
form, as Dataset, that stores your Dataset. Call it something like
MyDataSet.

Create Form1 and Form2. Form1 and Form2 inherit from your custom base form

Replace this in form1 and form2:

Inherits System.Windows.Forms.Form

with this:

Inherits MyBaseForm

They both now have access to the DataSet property. After you first retrieve
the Dataset, store it in the base forms property. Now, both forms can see
it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top