„SET QUOTED_IDENTIFIER OFF“ bleibt nach dem Öffnen eines Recordsets nicht bestehen [Duplikat]

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: „SET QUOTED_IDENTIFIER OFF“ bleibt nach dem Öffnen eines Recordsets nicht bestehen [Duplikat]

by Guest » 15 Jan 2025, 16:03

Ich finde ein Problem. Wenn ich eine ADO-Verbindung in C++ öffne und dann „SET QUOTED_IDENTIFIER OFF;“ aufrufe Um QUOTED_IDENTIFIER auszuschalten, kann ich eine Anweisung wie „Select „Test“;“ aufrufen.
Wenn ich jedoch ein Recordset öffne und es nicht schließe, dann rufen Sie „SET QUOTED_IDENTIFIER OFF;“ auf QUOTED_IDENTIFIER auszuschalten, wird nicht funktionieren. Rufen Sie eine Anweisung wie „Select „Test“;“ auf. wird eine Ausnahme auslösen. Warum?
Unten ist mein Beispielcode:

Code: Select all

#include 
#include 
#import "msado15.dll" rename("EOF", "AdoNativeEOF")

using namespace ADODB;

int main()
{
CoInitialize(NULL);

try
{
// Create ADO Connection
_ConnectionPtr pConnection;
pConnection.CreateInstance(__uuidof(Connection));

// Connection string - modify these values according to your environment
_bstr_t connStr = "Provider=SQLOLEDB;Data Source=(local);"
"Initial Catalog=MyTest;"
"Integrated Security=SSPI;";

pConnection->Open(connStr, "", "", adConnectUnspecified);

// If comment out the following statement, then "Select \"Test\";" will succeed, otherwise, it will fail.
// Open a recordset
_RecordsetPtr pRS = pConnection->Execute(
"SELECT SESSIONPROPERTY('QUOTED_IDENTIFIER')",
NULL,
adCmdText);

// Turn QUOTED_IDENTIFIER OFF
pConnection->Execute("SET QUOTED_IDENTIFIER OFF;", NULL, adCmdText | adExecuteNoRecords);

// Test
pConnection->Execute("Select \"Test\";", NULL, adCmdText | adExecuteNoRecords);

std::cout

Top