解决错误“找不到对象”,因为它不存在或您没有权限。

时间:2019-07-25 17:50:19

标签: sql asp.net-web-api

我有一个名为“ usp_bulk_import_request_pending”的存储过程,带有2个参数。我在数据库中执行了它,并且按我的意愿工作。 但 现在,我从webapi调用此存储过程并传递2个参数。 我收到错误消息“因为找不到对象“表名”,因为它不存在或您没有权限。”

Web api代码:

[HttpPost]
[ActionName("SaveImport")]
public void SaveImport([FromBody] dynamic param)
{         
 var args = new List<DBParameter>();
args.Add(new DBParameter("@requestorId", DbType.AnsiString, param.Sysm.ToString()));
            args.Add(new DBParameter("@importFileType", DbType.AnsiString, param.ImportFileType.ToString()));
            SQL.ExecuteNonQuery(Connection, "usp_bulk_import_request_pending", args.ToArray());  //error here
        }

Ajax调用:

Save: function (me) {
        Ext.Msg.confirm('Save', 'Are you sure you want to save imported data?', function (button) {
            if (button === 'yes') {
                var sysm = BIACore.Security.User.userId,
                    importfileType = 'COST';
                var params = { ImportFileType: importfileType, Sysm: sysm };
                Ext.getBody().mask('Save is in progress, please wait.')
                Ext.Ajax.request({
                    url: 'api/CostImport/SaveImport',
                    method: 'POST',
                    cache: false,
                    scope: this,
                    headers: {
                        "Content-Type": "application/json"
                    },
                    params: JSON.stringify(params),
                    success: function (response) {
                        Ext.getBody().unmask();
                        var tabPanel = this.getCurrent(),
                            currentTab = tabPanel.getActiveTab();
                        if (currentTab.title != 'Cost Import') {
                            tabPanel.setActiveTab(tabPanel.down('#costImport'));
                        } else {
                            var grid = this.getCurrent().getActiveTab();
                            var sysm = BIACore.Security.User.userId,
                                params = {
                                    RowId: '',
                                    ORIG_AIRPORT_CODE: '',
                                    DEST_AIRPORT_CODE: '',
                                    SERVICE_LEVEL: '',
                                    CURRENCY_CODE: '',
                                    LONG_TERM_COST: '',
                                    SHORT_TERM_COST: '',
                                    LONG_TERM_PERSISTENT_COST_DATE: '',
                                    SHORT_TERM_PERSISTENT_COST_DATE: '',
                                    CREATE_USER_NAME: sysm,
                                    ERRORS: '',
                                };
                            var store = grid.getStore();
                            store.getProxy().extraParams = params;
                            store.load();
                        }
                        Ext.MessageBox.alert('Save', 'Successfully saved import data.');                   
                    },
                    failure: function (response) {
                        Ext.getBody().unmask();
                        var responseReturn = Ext.decode(response.responseText);
                        Ext.MessageBox.show({
                            title: 'Save',
                            msg: responseReturn.ExceptionMessage,
                            icon: Ext.MessageBox.ERROR,
                            buttons: Ext.Msg.OK
                        });
                    }
                });
            }
        }, this);
    }

我找不到我要去哪里了?

1 个答案:

答案 0 :(得分:0)

尝试

 SQL.ExecuteNonQuery(Connection, "[dbo].usp_bulk_import_request_pending", args.ToArray());

装有

 SQL.ExecuteNonQuery(Connection, "usp_bulk_import_request_pending", args.ToArray());

并为此用户设置执行权限