|
-
May 28th, 2001, 07:43 AM
#1
Help... Error when trying to fill a DataSet.
I get the following message when I try to fill a dataset with output from a stored procedure... "expected TableMappings['Table'] to exist." Debugging goes all the way down to sqlDSCommand.FillDataSet(dsInvoice);
Below is the code snippet I run. I thought DataSets were filled automatically and that they use the mappings set in the stored procedure. What's wrong?
Code notes - periodBegin and periodEnd are parameters where dates are stored. Added the second row (dsInvoice.Table.Add) recently but I still got the same error message.
dsInvoice = new DataSet();
dsInvoice.Tables.Add("InvoiceBasis");
sqlDSCommand = new SQLDataSetCommand(spName, sqlConn);
sqlDSCommand.SelectCommand.ActiveConnection.Open();
try
{
sqlDSCommand.SelectCommand.Parameters.Add(new SQLParameter("@FromDate", SQLDataType.DateTime));
sqlDSCommand.SelectCommand.Parameters["@FromDate"].Direction = ParameterDirection.Input;
sqlDSCommand.SelectCommand.Parameters["@FromDate"].Value = periodBegin;
sqlDSCommand.SelectCommand.Parameters.Add(new SQLParameter("@ToDate", SQLDataType.DateTime));
sqlDSCommand.SelectCommand.Parameters["@ToDate"].Direction = ParameterDirection.Input;
sqlDSCommand.SelectCommand.Parameters["@ToDate"].Value = periodEnd;
sqlDSCommand.FillDataSet(dsInvoice);
}
finally
{
sqlDSCommand.SelectCommand.ActiveConnection.Close();
}
-
June 8th, 2001, 08:35 PM
#2
Re: Help... Error when trying to fill a DataSet.
hi,
In beta 1, datasets get filled automatically, but you have to specify the table name to the dataset while filling. This table name should corrospond to the table name in the database.
Hence change this line ...
sqlDSCommand.FillDataSet(dsInvoice,"TableName");
change the "TableName", to whatever is the name of the table you are retriving ..
Saurabh Nandu
mail[email protected]
http://Learncsharp.cjb.net
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
|