views:

36

answers:

1
DataTable NetPurch = new DataTable();

DataColumn[] Acct_n_Prod = new DataColumn[2]; 
DataColumn Account;
Account = new DataColumn();
Account.DataType = typeof(string);
Account.ColumnName = "Acct";

DataColumn Product;
Product = new DataColumn();
Product.DataType = typeof(string);
Product.ColumnName = "Prod";

NetPurch.Columns.Add(Account);
NetPurch.Columns.Add(Product);

Acct_n_Prod[0] = Account;
Acct_n_Prod[1] = Product;

NetPurch.PrimaryKey = Acct_n_Prod;

NetPurch.Columns.Add(MoreColumns);

the code is based on the example here

When it is compiled and runs i get an error saying:

"Expecting 2 values for the key being indexed but received only one"

if I make Acct_n_Prod = new DataColumn[1]

and comment out the line adding product to the acct-n-prod array then it runs fine

I'm fairly new to this so I'm not sure where the error is

Thanks,

-Mike

A: 

Your're right BFree, there was some other code (which I was oblivious to) there that was throwing an exception. I've been banging my head on this for 2 days thanks.

Mike