Tengan
May 28th, 2001, 07:43 AM
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();
}
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();
}