Results 1 to 3 of 3

Thread: Exception occure when use datagrid to present Data from database

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2002
    Posts
    5

    Exception occure when use datagrid to present Data from database

    Hello,
    I'm new comer to VB.NET, I'm trying to write a simple form, use datagrid to present data from a DataSet. I use only one table in dataset, and I can preview full data in sqlDataAdapter, as I desire, at design time. In the form I have a "View" button allow display full data selected from database in datagrid at runtime, the code for click event as follow:

    Private Sub cmdView_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdView.Click
    Area.Clear()
    SqlDataAdapter_Area.Fill(Area, "Area")
    End Sub

    In that: "Area" is dataset's name, and "SQLDataAdapter_Area" is DataAdapter's name of dataset Area

    It's seem nothing wrong at design time but at the runtime when I click button "View", I got an exception like that:

    An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in system.data.dll

    I don't understand this message, can you tell me ?
    Thanks in advance
    Last edited by www; Jul 28th, 2002 at 11:06 PM.

  2. #2
    Lively Member Dr_Evil's Avatar
    Join Date
    Mar 2000
    Location
    Columbus, OH
    Posts
    105
    I have tested your code and everything works fine here. The SQLException could be caused by any number of things. An invalid SQL statement, invalid connection string etc. It's hard to tell without the app in front of me. I must say it is strange that you can preview the data at design time, but it throws an exception at runtime. Let me know if you need help, I'd be more than willing to take a look at your app if you zip and email it to me.
    Dr_Evil
    Senior Programmer
    VS6 EE
    VS.NET EA

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2002
    Posts
    5

    Thanks

    Thanks Dr Evil,
    It's difficult to understand, It's run well after I try to re-write code and re-create all the control on the form again. I don't know what is the mistake , so I can't send you the wrong file now. Anyway, thanks for your goodness and I wonder: If I can direct send you email whenever I got trouble with VB.
    Thanks

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