473,491 Members | 1,965 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

OleDBCommand does not contain a definition for 'Fill'?

Was browsing around online for code to connect to a database usign ADO
and C#... and i found this very simple but useful reference
(http://www.c-sharpcorner.com/database/db_list.asp)

However, implementing this into my own project does seem to work.

I'm getting an error: 'System.Data.OleDb.OleDbCommand' does not
contain a definition for 'Fill'

Why would this be?

PS - code below for reference.

private void Form1_Load(object sender, System.EventArgs e)
{
string strDSN = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=photoDB.MDB";
string strSQL = "SELECT * FROM photos" ;

// create Objects of ADOConnection and ADOCommand
OleDbConnection myConn = new OleDbConnection(strDSN);
OleDbCommand myCmd = new OleDbCommand( strSQL, myConn );

myConn.Open();
DataSet dtSet = new DataSet();
myCmd.Fill( dtSet, "photos" );
DataTable dTable = dtSet.Tables[0];

foreach( DataRow dtRow in dTable.Rows )
{
listBox1.Items.Add( dtRow["Name"].ToString());
listBox1.Items.Add( dtRow["Address"].ToString());
}
Nov 16 '05 #1
1 3467
Brian,

This is because the OleDbCommand does not have a method of Fill. If you
look at the example again (that you posted) you will see that they are using
an OleDbDataAdapter not an OleDbCommand object. I have provided a sample
below for you.

Hope this helps.

-------------------------------
OleDbConnection conn = new OleDbConnection(strConn);
DataSet ds = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter("SELECT * FROM authors",conn);
da.Fill(ds);
Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1852
by: Jason Steeves | last post by:
-Dim cmd As OleDbCommand -cmd = New OleDbCommand("select * from qmsstats where firstname='jason'", OleDbConnection1) -OleDbDataAdapter2.SelectCommand = cmd -DataGrid1.Visible = True...
5
1641
by: bardo | last post by:
I have a question about the OleDBCommand. I am making a program that needs to load 6 tabels from a Access DataBase. At the moment I got everything working by making 6 Adapters, CommandBuilders...
4
2383
by: Arjen | last post by:
What does this mean? 'Roles' does not contain a definition for 'RoleExists' I'm doing this: using System.Web.Security; Roles.DeleteRole(txtRolename.Text.Trim()); I don't see what's wrong. ...
3
11945
by: ohayo | last post by:
In a windows form app (which acts as a front end to my quickfix application), I get the following error on compiling Application does not contain a definition for 'Run'. What does this mean,...
2
2200
by: etropic | last post by:
I am trying to bind two tables to two different list boxes Ther tables are working as I use them on another page wth no problems The code is as follows... private void Page_Load(object...
1
6774
by: Luis Esteban Valencia | last post by:
Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source...
1
3065
by: Chris Fink | last post by:
Why does this timeout after 10 secs, instead of the higher value expected? OleDbConnection cn = new OleDbConnection(Session.ToString()); OleDbDataAdapter adapter = new OleDbDataAdapter();...
4
2412
by: Agnes | last post by:
Dim authConnection As New OleDbConnection("Provider = VfpOleDB.1;Data Source = d:\cgl\vfpmaster\ttsdata\tts.dbc") authConnection.Open() Dim authCommand As String = "select loginid from coinfo...
1
7820
by: mfunkmann | last post by:
Hi, I recently got an error and I don't know how to fix it: Error 1 'System.Data.DataColumn' does not contain a definition for 'Windows' C:\c#\CsharpPRO\Form1.Designer.cs 304 77 CsharpPRO I...
0
7118
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7192
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5452
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4579
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3087
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1397
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
637
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.