Error with datagrid

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tonya

    #1

    Error with datagrid

    hi,

    I am trying to setup a datagrid that pulls values from a
    database but i keep getting an error message when i run
    the application. Can anyone help me??
    The application stops at the line:
    da2.fill(ds2)

    i keep getting the following error message:

    An unhandled exception of
    type 'System.Data.Sq lClient.SqlExce ption' occurred in
    system.data.dll


    here is my code leading up to this:

    da2 = New SqlDataAdapter( "SELECT Meal_Desc, 0 as Quantity
    FROM Equipment_Detai ls", Cn)

    ds2 = New DataSet("MealBo oking")
    da2.Fill(ds2)

    DGridMealBookin g.DataSource = ds2.Tables(0)


    this code is in the form_load event.
    I have another datagrid being filled just above this one
    shown above.

    I have instantiated outside of the form load as:
    Private da2 as SqlDataAdapter
    Private ds2 as dataset

    Can anyone help? i have no idea what i have done wrong!!

    thx
  • William Ryan

    #2
    Re: Error with datagrid

    The SQLException doesn't have anything to do with the grid. First make sure
    you have a good connection/connectionstrin g. Then make sure you can run the
    query in QA b/c if you have a bad query, it's going to blow up on you..

    My guess is that's it's your query, but I'd check the connection too. You
    can try just for testing, YourConnection. Open right before the Da.Fill and
    make sure it doesn't throw an exception. If it works, it's probably that 0
    as a column name.

    HTH,

    Bill
    "Tonya" <s@dis> wrote in message
    news:1e0e01c3ae ef$7d860de0$a60 1280a@phx.gbl.. .[color=blue]
    > hi,
    >
    > I am trying to setup a datagrid that pulls values from a
    > database but i keep getting an error message when i run
    > the application. Can anyone help me??
    > The application stops at the line:
    > da2.fill(ds2)
    >
    > i keep getting the following error message:
    >
    > An unhandled exception of
    > type 'System.Data.Sq lClient.SqlExce ption' occurred in
    > system.data.dll
    >
    >
    > here is my code leading up to this:
    >
    > da2 = New SqlDataAdapter( "SELECT Meal_Desc, 0 as Quantity
    > FROM Equipment_Detai ls", Cn)
    >
    > ds2 = New DataSet("MealBo oking")
    > da2.Fill(ds2)
    >
    > DGridMealBookin g.DataSource = ds2.Tables(0)
    >
    >
    > this code is in the form_load event.
    > I have another datagrid being filled just above this one
    > shown above.
    >
    > I have instantiated outside of the form load as:
    > Private da2 as SqlDataAdapter
    > Private ds2 as dataset
    >
    > Can anyone help? i have no idea what i have done wrong!!
    >
    > thx[/color]


    Comment

    Working...