Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Try
           Dim con As New OleDbConnection 'connection. 
           Dim da As New OleDbDataAdapter 'data adapter for connection. 
           Dim MyDS As New DataSet  'dataset to be filled by data adapter. 

           Dim querySQL As String = "SELECT * FROM dbinfo ORDER BY dblast"
           Dim connectString As String = "Provider= Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath & "\dbdata.mdb"

           con = New OleDbConnection(connectString)
           da = New OleDbDataAdapter(querySQL, connectString)
           da.Fill(MyDS)

       Catch ex As Exception
           Dim form7 As New Form7
           form7.Show()
           DBError() ' Disables all but the restore button.
       End Try

 

The above code works fine. However, if I try to use the MyDS dataset name anywhere, in any other section of the app, I get the "Name 'MyDS' not declared." This is driving me nuts.

 

That code is in the form_load procedure. If I try to call myds anywhere inside or outside the load procedure, it won't work. the da.fill(myds) works fine (does not give me an error during design) and I can compile it. But if I try to add something like

 

records = me.bindingcontext(myds, "dbinfo").count

 

it won't take that. When I had the dataset configured by the designer wizard, this all worked fine, but my requirements have changed since then and I can't use the wizard anymore.

Posted

Try

Dim con As New OleDbConnection 'connection.

Dim da As New OleDbDataAdapter 'data adapter for connection.

Dim MyDS As New DataSet 'dataset to be filled by data adapter.

...

 

Take it outside of try ...anywhere else it's out of scope.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...