Results 1 to 6 of 6

Thread: Tossing My Computer Out Window.. (DATA Help)

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2002
    Location
    Canton, GA
    Posts
    487

    Tossing My Computer Out Window.. (DATA Help)

    sigh ok,,,,

    my MS SQl DB is sitting on my web server... I have created a connection and such and can get it to display data if I "Preview Data" from inside the editor...

    I placed this on my formload but I keep getting the following error... any suggestions?


    My Code:


    SqlCommand1.CommandText = "SELECT * FROM Employees"
    SqlDataAdapter1.SelectCommand = SqlCommand1
    Me.DataSet11.Clear()
    SqlDataAdapter1.Fill(DataSet11)

    ----------------------------------

    Error:

    An unhandled exception of type 'System.InvalidOperationException' occurred in system.data.dll

    Additional information: Fill: SelectCommand.Connection property has not been initialized.

    and it will heighlight the line:

    SqlDataAdapter1.Fill(DataSet11)

    ???

    any help?

    Anjari

  2. #2
    Junior Member
    Join Date
    Sep 2002
    Location
    Florida
    Posts
    24
    you need to open your connection before you fill your dataset

    sqlconnection1.open

    then close it when done

    sqlconnection1.close

  3. #3
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    Fort Collins, CO
    Posts
    366
    you don't need to open and close a connection with the dataadapter(the Fill method takes care of that for you). But you need to make sure your command has a connection associated with it. mycommand.connection = yourconnectionobject
    Last edited by pvb; Apr 17th, 2003 at 01:35 PM.

  4. #4
    Junior Member
    Join Date
    Sep 2002
    Location
    Florida
    Posts
    24
    yeah, it doesn't need to be opened...sorry thought it did because the dataform wizard puts that code in there for you...why?, i have no idea

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2002
    Location
    Canton, GA
    Posts
    487

    hmmm

    mycommand.connection = yourconnectionobject
    Elaborate on the "yourconnectionobject" part please...

    Anjari

  6. #6
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    yourconnectionobject is simply the name of connection you use to connect to your sql server.
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

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