Click here to Skip to main content
15,914,780 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

When I am trying to use some thing like this


C#
OleDbDataAdapter command = new OleDbDataAdapter();

               command.Fill(dataSet);
               connection.Close();


I am getting a exception like below.
Details: The SelectCommand property has not been initialized before calling 'Fill'

How to solve this problem??


Thanks
John
Posted

one is
command.SelectCommand = "Your query";


and second is connection path to your database
 
Share this answer
 
The error you get is pretty self explanatory: you have to initialize the SelectCommand property of your command variable before trying to call its Fill() method.
This way:
C#
command.SelectCommand = "SELECT [myField] FROM [IShouldReadErrorMessagesMoreCarefully]";
 
Share this answer
 
Please, visit this site: OLEDB Tutorial (C#)[^]. There you'll find what you're looking for ;)
 
Share this answer
 
Select Command is missing for this Connection object.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900