|
-
Apr 17th, 2003, 12:27 PM
#1
Thread Starter
Hyperactive Member
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
-
Apr 17th, 2003, 01:21 PM
#2
Junior Member
you need to open your connection before you fill your dataset
sqlconnection1.open
then close it when done
sqlconnection1.close
-
Apr 17th, 2003, 01:31 PM
#3
Hyperactive Member
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.
-
Apr 17th, 2003, 01:36 PM
#4
Junior Member
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
-
Apr 18th, 2003, 01:31 AM
#5
Thread Starter
Hyperactive Member
hmmm
mycommand.connection = yourconnectionobject
Elaborate on the "yourconnectionobject" part please...
Anjari
-
Apr 18th, 2003, 01:47 AM
#6
Frenzied Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|