Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetStoredProcCommand("sp_CustomerStorageReport"); --CustomerNo是变量吗?这么写对吗?报什么错?
db.AddInParameter(dbCommand, "customer", DbType.String, CustomerNo); 
db.AddInParameter(dbCommand, " startdatetime", DbType.DateTime, startdate); 
db.AddInParameter(dbCommand, " enddatetime", DbType.DateTime, enddate); 
DataSet ds = db.ExecuteDataSet(dbCommand); 
return ds; 

解决方案 »

  1.   

     dbCommand.CommandType = CommandType.StoredProcedure;
      

  2.   

    Visual Basic
    Public Overridable Function GetStoredProcCommand ( _
        storedProcedureName As String, _
        ParamArray parameterValues As Object() _
    ) As DbCommand
    C#
    public virtual DbCommand GetStoredProcCommand (
        string storedProcedureName,
        params Object[] parameterValues
    )
    C++
    public:
    virtual DbCommand^ GetStoredProcCommand (
        String^ storedProcedureName, 
        ... array<Object^>^ parameterValues
    )
    J#
    public DbCommand GetStoredProcCommand (
        String storedProcedureName, 
        Object[] parameterValues
    )
    JScript
    public function GetStoredProcCommand (
        storedProcedureName : String, 
        ... parameterValues : Object[]
    ) : DbCommand