ASP.netアプリがあり、次の接続文字列を使用しています。
<configuration>
<connectionStrings>
<add name="CAF" connectionString="Data Source=pxx-sql2;Initial Catalog=mydb;User ID=DBUser;Password=mypass;Persist Security Info=False;Trusted_Connection=False;" providerName="System.Data.SqlClient"/>
</connectionStrings>
</configuration>
アプリケーションを読むと、すべてが機能します。しかし、私が書いているとき、私はこのエラーを受け取ります:「OLEDBプロバイダー'ADSDSOObject'へのアドホックアクセスが拒否されました。リンクサーバーを介してこのプロバイダーにアクセスする必要があります。」
提供されるスタックトレース:
[SqlException (0x80131904): Ad hoc access to OLE DB provider 'ADSDSOObject' has been denied. You must access this provider through a linked server.]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +404
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() +412
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1363
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +6387805
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +6389506
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +538
System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +689
System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +327
MyDBData.Reconcile(HttpRequest req, User u, String assignee) in c:\websites\MyDB\App_Code\MyDBDataReconciler.cs:99
[Exception: Ad hoc access to OLE DB provider 'ADSDSOObject' has been denied. You must access this provider through a linked server.]
MyDBData.Reconcile(HttpRequest req, User u, String assignee) in c:\websites\MyDB\App_Code\MyDBDataReconciler.cs:112
EntryEditView.Page_Load(Object sender, EventArgs e) in c:\websites\MyDB\EntryEditView.aspx.cs:50
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +25
BasePage.OnLoad(EventArgs e) in c:\websites\MyDB\App_Code\BasePage.cs:19
System.Web.UI.Control.LoadRecursive() +71
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3064
このプロジェクトのどこでも「ADSDSOObject」を使用しているとは思わないことを除いて。標準のSqlDataハンドルで接続を開いています。
本当に奇妙なのは、これが4つの挿入の4番目でありExecuteNonQuery
、トランザクションをコミットする前の最後の挿入であるということです。
これが全体としての機能です。
public void Reconcile(HttpRequest req, User u, string assignee)
{
SqlConnection conn = new SqlConnection(Config.ConnString);
conn.Open();
SqlTransaction transaction = conn.BeginTransaction("UpdateMyDB");
this.master.MyDBMasterID = int.Parse(req.Params["MyDB"]);
MyDBLayout MyDBL = new MyDBLayout(this.master.MyDBMasterID);
this.master.bexMasterID = int.Parse(req.Params["bex"]);
MyDBLayout bexL = null;
if (this.master.bexMasterID > 0)
bexL = new MyDBLayout(this.master.bexMasterID);
SqlCommand cmd = new SqlCommand();
cmd.Transaction = transaction;
cmd.Connection = conn;
try
{
int bexForm;
if (this.MyDBID == -1)
{
// Create the blank MyDB
cmd.CommandText = @"
insert into MyDB_Master(created, branch, client, clientName, submitter, specialist, MyDBDate, MyDBMasterID, bexMasterID)
values (getdate(), '', '', '', @submitter, '', getdate(), @MyDBMasterID, @bexMasterID); select @@IDENTITY";
cmd.Parameters.AddWithValue("@MyDBMasterID", req.Params["MyDB"].Trim());
cmd.Parameters.AddWithValue("@submitter", u.LoginName);
bexForm = int.Parse(req.Params["bex"].Trim());
if (bexForm != -1)
cmd.Parameters.AddWithValue("@bexMasterID", bexForm);
else
cmd.Parameters.AddWithValue("@bexMasterID", DBNull.Value);
MyDBID = (int)((decimal)cmd.ExecuteScalar());
}
// Populate the master
cmd.CommandText = @"
update MyDB_MASTER set branch = @branch, client = @client, clientName = @clientName,
specialist = @specialist, MyDBDate = @MyDBDate,
MyDBMasterID = @MyDBMasterID, bexMasterID = @bexMasterID, payDate = @MyDBPayDate, method = @method
where MyDBID = @MyDBID;";
cmd.Parameters.Clear();
cmd.Parameters.AddWithValue("@MyDBID", MyDBID);
cmd.Parameters.AddWithValue("@branch", req.Params["MyDBBranch"].Trim());
cmd.Parameters.AddWithValue("@client", req.Params["MyDBClient"].Trim());
cmd.Parameters.AddWithValue("@clientName", req.Params["MyDBName"].Trim());
cmd.Parameters.AddWithValue("@specialist", req.Params["MyDBSpecialist"].Trim());
cmd.Parameters.AddWithValue("@method", req.Params["MyDBMethod"].Trim());
DateTime MyDBDate = DateTime.MinValue;
if (DateTime.TryParseExact(req.Params["MyDBDate"], "MM/dd/yyyy", enUS, DateTimeStyles.AllowWhiteSpaces, out MyDBDate))
cmd.Parameters.AddWithValue("@MyDBDate", MyDBDate);
else
cmd.Parameters.AddWithValue("@MyDBDate", DateTime.Now);
DateTime MyDBPayDate = DateTime.MinValue;
if (DateTime.TryParseExact(req.Params["MyDBPayDate"], "MM/dd/yyyy", enUS, DateTimeStyles.AllowWhiteSpaces, out MyDBPayDate))
cmd.Parameters.AddWithValue("@MyDBPayDate", MyDBPayDate);
else
cmd.Parameters.AddWithValue("@MyDBPayDate", DBNull.Value);
cmd.Parameters.AddWithValue("@MyDBMasterID", req.Params["MyDB"].Trim());
bexForm = int.Parse(req.Params["bex"].Trim());
if (bexForm != -1)
cmd.Parameters.AddWithValue("@bexMasterID", bexForm);
else
cmd.Parameters.AddWithValue("@bexMasterID", DBNull.Value);
cmd.ExecuteNonQuery();
// Remove old detail
cmd.Parameters.Clear();
cmd.CommandText = @"delete from MyDB_detail where MyDBID = @MyDBID";
cmd.Parameters.AddWithValue("@MyDBID", MyDBID);
cmd.ExecuteNonQuery();
FixNotes(MyDBID, req, cmd);
AddDetail(MyDBID, MyDBL, req, cmd);
if ( bexL != null )
AddDetail(MyDBID, bexL, req, cmd);
cmd.Parameters.Clear();
cmd.CommandText = @"insert into MyDB_history (MyDBID, alteredBy, assignedTo, status) values (@MyDBID, @alteredBy, @assignedTo, @status)";
cmd.Parameters.AddWithValue("@MyDBID", MyDBID);
cmd.Parameters.AddWithValue("@alteredBy", u.LoginName);
cmd.Parameters.AddWithValue("@assignedTo", assignee);
cmd.Parameters.AddWithValue("@status", req.Params["MyDBStatus"]);
this.master.assignedTo = assignee;
cmd.ExecuteNonQuery(); // <--- Fails here.
transaction.Commit();
}
catch (System.Exception e)
{
try
{
transaction.Rollback();
}
catch { }
throw new Exception(e.Message, e);
}
}
この特定のエラーの原因は何ですか?