Something interesting that was discovered lately. When running stored procedures between Odbc and OleDB via the .NET 1.1 Command objects, there are incompatibilities.
So given this code snippet...
/*Works for Odbc*/
OdbcCommand cmd = new OdbcCommand(connString);
cmd.Text = "exec sp_help ?";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@Table",tableName);
OdbcDataAdapter adapt = new OdbcDataAdapter(cmd);
adapt.Fill(dataSet);
the execution will go through succesfully.
However, if you change OdbcCommand to OleDbCommand, the snippet will fail.
This will work for OleDb but not Odbc, and is often the way I had used it for SqlCommand.
cmd.Text = "sp_help";
cmd.CommandType = CommandType.StoredProcedure;
And this will work for both Odbc and OleDb but I have not tested against SqlCommand.
/*Works for Both*/
cmd.Text = "{call sp_help ?}";
cmd.CommandType = CommandType.Text;
Later on I'll create a test project that will test all 3 Command objects.
Friday, August 04, 2006
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment