Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Object must implement IConvertible error during DataAdapter.Fill?

Status
Not open for further replies.

DLLHell

Programmer
May 9, 2003
69
US
I have a DB2 Stored Procedure (not ODBC) that connects & executes fine via an OleDbDataAdapter, but when the ASP.NET page tries to do a Fill, I get the "Object must implement IConvertible error". Does anyone know what this problem might be? I am guessing that it must involve the DB2 data types - if so where would IConvertible be used? This error occurs whether I try to .Fill to a DataTable, DataSet or an XML DataSet. It worked fine with SQL Server data though.

dsXX1.Clear();
objDataAdapter.Fill(dsXX1); //Abends here IConvertible
DataGrid1.DataBind();

Any thoughts or leads on this would be greatly appreciated. Thanks.
 
Hi James, here is the ADO code. The Stored Procedure is just a Cobol pgm that just Opens a Cursor. It then returns a RecordSet that Fills the DataGrid. It works fine in VB but this is the 1st time I am trying it in C# & .NET.


private void btnSearch_Click(object sender, System.EventArgs e)

{
string connString = ("Provider=IBMDADB2.1;" +
"Password=xxxxxxxx;" +
"User ID=xxxxxxxx;" +
"Data Source=DB2DSN;" +
"Mode=Read;" +
"Extended Properties=;" + "CURRENTFUNCTIONPATH=DVVV,SYSIBM,SYSPROC,SYSFUN;");

//Create the Connection Object passing the connection string to the constructor
OleDbConnection objConnect = new OleDbConnection(connString);
//Open the connection to the database
objConnect.Open();

//This is the name of the Stored Procedure to run.
string SQL = "STOREDPROCNAME";

OleDbDataAdapter objDataAdapter = new OleDbDataAdapter(SQL, connString);
objDataAdapter.SelectCommand.CommandType = CommandType.StoredProcedure;

//Instantiate a new OleDBParameter object. Passes 3 arguments
//1. “Stored Procedure variable name”
//2. OleDBType (i.e. Char, int, varchar, etc)
//3. Size

//Input parameter - Number
OleDbParameter param = new OleDbParameter("@NBR", OleDbType.Char, 6);
param.Value = strNbr;
param.Direction = ParameterDirection.Input;
objDataAdapter.SelectCommand.Parameters.Add(param);

// dsXX1 is an XML file to receive the RecordSet Results into the DataGrid
dsXX1.Clear();
objDataAdapter.Fill(dsBV1); //Abends here IConvertible error
DataGrid1.DataBind();

//Close the Connection. This is not handled through Garbage Collection.
objConnect.Close();
}
 
Hi,

you need to pass a DataSet into the DataAdapters fill method. I can't see the declaration of dsBV1, but if dsXX1 is an XMLDocument, or XMLDataDocument then thats what is causing the error if that is what you mean that you are passing in.

I don't think it is the DatAdapter that is at fault but what you are passing into the fill method. COuld be wrong though.

James :)

James Culshaw
james@miniaturereview.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top