visual studio 2005 TableAdpter自动生成返回值的类型

例如: select count(*) from
理论上返回:int类型的数字一个
但是实际上IDE自动生成代码有时候会是:
ScalarCallRetval="System.Object, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
但应该是:
ScalarCallRetval="System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
那应该怎么解决?
MSDN上这样写到:

To execute a TableAdapter query that returns a single (scalar) value

  • Create an instance of the TableAdapter, declare a variable to hold the return value, and assign it the result of the query. The following example assumes that there is a query named CustomerCount on the QueriesTableAdapter.

    NorthwindDataSetTableAdapters.QueriesTableAdapter scalarQueriesTableAdapter;
    scalarQueriesTableAdapter 
    = new NorthwindDataSetTableAdapters.QueriesTableAdapter();

    int returnValue;
    returnValue 
    = (int)scalarQueriesTableAdapter.CustomerCount();

     

posted @ 2007-11-09 10:12  Fernando  阅读(557)  评论(0编辑  收藏  举报