#1 ds.Fill problem

closed-invalid
nobody
None
5
2003-12-09
2003-12-06
Anonymous
No

Here is my code:

conn = new SQLiteConnection ("Data
Source=Northwind.db");
conn.Open();

SQLiteCommand cmd =
(SQLiteCommand) conn.CreateCommand();
cmd.CommandText = "Select * from
Customers";
IDbDataAdapter custAdapter = new
SQLiteDataAdapter();
custAdapter.SelectCommand = cmd;

SQLiteCommand cmd2 =
(SQLiteCommand) conn.CreateCommand();
cmd2.CommandText = "Select *
from Orders";
IDbDataAdapter ordAdapter = new
SQLiteDataAdapter();
ordAdapter.SelectCommand = cmd;

DataSet ds = new DataSet();

custAdapter.Fill(ds, "Customers");
ordAdapter.Fill(ds, "Orders");

DataRelation custOrderRel =
ds.Relations.Add("CustOrders",
ds.Tables
["Customers"].Columns["CustomerID"],
ds.Tables
["Orders"].Columns["CustomerID"]);

this.dataGrid1.DataSource = ds;

Getting a compiler error:
[C# Error] frmMain.cs(463): No overload for method 'Fill'
takes '2' arguments
e:\WINDOWS\Microsoft.NET\Framework\v1.1.4322
\System.Data.dll: (Location of symbol related to
previous error)

It does work if I change to custAdapter.Fill(ds) - but it
only works with one table. Any thoughts would be
appreciated.

Dave

Discussion

  • Tim McDaniel
    Tim McDaniel
    2003-12-09

    • status: open --> closed-invalid
     
  • Tim McDaniel
    Tim McDaniel
    2003-12-09

    Logged In: YES
    user_id=896420

    Change "IDbDataAdapter" to "SQLiteDataAdapter" and it
    should work.

    IDbDataAdaptor defines only one Fill method, which takes
    only one parameter. SQLiteDataAdapter inherits from
    DbDataAdapter, which defines several overloaded Fill
    methods. Look up DbDataAdapter to find the details.