Results 1 to 8 of 8

Thread: Error 91 when dim datatable

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    4

    Unhappy Error 91 when dim datatable

    Hi all,

    I am new to VB.net and this may be very basic.

    I am writing a program that retrieves data from a SQL Server 2000 DB. I present this info in a datagrid.

    User needs to select some of the rows and I transfer the selected row to another datagrid (grdLoc)

    I need to build the data source for the grdLoc dynamically.

    This is my code

    Dim dt as DataTable = new datatable ("Locations")
    Dim dt as DataView
    Dim dr as DataRow

    Debugging the system, I get an error 91 in the Dim dt as datatable.

    When I specify the full path in the statement:

    dim dt as system.data.datatable

    then I get this error:

    Public member 'tables' on type 'DataTable' not found

    I am at a loss. I have in my imports:

    System
    System.Data
    System.SQLClient
    Microsoft.VisualBasic

    Is there something am I missing?.


    Thanks for your help



    Luisa

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    105,436

    Re: Error 91 when dim datatable

    What version of VB.NET are you using? Is this a Windows app or a Web app?

  3. #3
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    35,235

    Re: Error 91 when dim datatable

    What is error 91?
    My usual boring signature: Nothing

  4. #4

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    4

    Error 91 when dim datatable

    Sorry this took so long.

    I am using Visual Studio .net 2003.


    I discovered that even though I get this error 91 (no description err.description is blank), if I clear the error (err.clear) the datatable object is created and I can work with it.


    Thanks for your support



    Luisa

  5. #5

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    4

    Re: Error 91 when dim datatable

    Sorry I forgot to mention that it is a windows application.

    I am using W-XP SP2.

    SQL Server 2000 - SP3.



    Luisa

  6. #6
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    35,235

    Re: Error 91 when dim datatable

    Uhhhh....err object? Sounds like old On Error Goto style of error handling. I can believe that you would get very limited information out of that. Try structured exception handling instead:

    Try
    <code that might throw an error here>
    catch ex as exception
    <do something with the exception here>
    Finally
    <optional code to run whether or not an error occurs>
    End Try

    Trap the specific type of exception that is being thrown and you will get the most specific error information. Trapping all exceptions as I have there will give you a message with ex.Message (not description, which is why I suspect On Error coding), but the generic exception message will not be very informative.

    In your case, I think you will be wanting to trap:

    System.Data.OLEDB.OLEDBException

    or something like that, though this may not necessarily be an OLEDB exception.

    Also, though your code works with the fix you found, it can't be an optimal solution to leave the error causing situation in there. Something is going on, it just isn't quite clear what. I looked into MSDN, and found the exact line you say is causing you trouble, so syntactically you are correct. The error must lie elsewhere, and it would be better to know thine enemy.

    Oh yeah, welcome to the forums, too.
    My usual boring signature: Nothing

  7. #7
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    105,436

    Re: Error 91 when dim datatable

    Calling ToString on the Exception object will give you maximum information about the error. It is a combination of Message, StackTrace and more.

  8. #8

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    4

    Re: Error 91 when dim datatable

    Thanks for the both replies. Very detailed and with excellent suggestions.


    I will add the Try ---- block ot see the exception.

    I started playing with the Datatable , dataviews etc to better understand the relationships with teh datasource of the grid.

    I created a brand new solution/project and started creating the form again. I do not get the error in this new project. So I assume that something got corrupt or bad in the original project file.


    I like the suggestion of the Try block so I am going to use it.


    Luisa

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