Results 1 to 6 of 6

Thread: Acess dataset between 2 Windows Form

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2003
    Posts
    8

    Question Acess dataset between 2 Windows Form

    Dear all
    If I have 2 form, 1 call form1 and the other call form2.
    I create a connection in form1:


    CLASS FORM1
    PUBLIC DS As DATASET

    Dim connstr As String = "DSN=TEST"
    Dim cn As New OdbcConnection(connstr)
    Dim DA1 As New OdbcDataAdapter("SELECT * FROM A ", cn)

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    cn.Open()
    odbcadapter1.Fill(DS, "A")

    I can successfully access DS in form1, but when I try to access DS in form2, it said" object reference not set to instance of object". It seem that it treat it as a new variable. I try this in form2:

    Dim zds As DataSet

    zds = form1.ds
    messagebox.show(zds.tables("A").Rows.count)

    But still not work. Anyone can told me how to access it from anothe table? Thank you very much.
    Last edited by fung1223; Jul 30th, 2003 at 04:20 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width