I have a vb script that uses odbc.connection that connects to the sql
server, snippet as shown:
szADOConnObjID = "ADODB.Connection";
set pADOConnObj = CreateObject(szADOConnObjID);
// Create the SQL string to complete the connection
szConnString = "driver={" + svDriver + "};";
szConnString = szConnString + "server=" + svServerName + ";";
if (g_bWinAuth = FALSE) then
szConnString = szConnString + "database=master;";
szConnString = szConnString + "uid=" + svUserName + ";";
szConnString = szConnString + "pwd=" + svUserPassword;
else // windows authorization
szConnString = szConnString + "Initial Catalog=master;";
szConnString = szConnString + "Integrated security=True";
endif;
// Open the ADO Connection
pADOConnObj.Open(szConnString);
I have no problem with the login with uid-pwd. However, if I use windows
authorization, I got the following error:
Microsoft OLE DB Service Components (0x80040E21)
Multiple-step OLE DB operation generated errors. Check each OLE DB
status value, if available.
Is my connection string correct?
TIA.Hi
I assume you can use a trusted connection from other application with this
login?
Try the connection string
Driver={SQL
Server};Server=myServerAddress;Database=myDataBase;Trusted_Connection=Yes;
as described for an ODBC connection in:
http://www.connectionstrings.com/?carrier=sqlserver
John
"Light" wrote:
> I have a vb script that uses odbc.connection that connects to the sql
> server, snippet as shown:
> szADOConnObjID = "ADODB.Connection";
> set pADOConnObj = CreateObject(szADOConnObjID);
> // Create the SQL string to complete the connection
> szConnString = "driver={" + svDriver + "};";
> szConnString = szConnString + "server=" + svServerName + ";";
> if (g_bWinAuth = FALSE) then
> szConnString = szConnString + "database=master;";
> szConnString = szConnString + "uid=" + svUserName + ";";
> szConnString = szConnString + "pwd=" + svUserPassword;
> else // windows authorization
> szConnString = szConnString + "Initial Catalog=master;";
> szConnString = szConnString + "Integrated security=True";
> endif;
> // Open the ADO Connection
> pADOConnObj.Open(szConnString);
> I have no problem with the login with uid-pwd. However, if I use windows
> authorization, I got the following error:
> Microsoft OLE DB Service Components (0x80040E21)
> Multiple-step OLE DB operation generated errors. Check each OLE DB
> status value, if available.
> Is my connection string correct?
> TIA.
>|||Hi Light,
You may try John's suggestion first. Also, I would like to know:
What is the result if you change your code for windows authentication to
the following code:
szConnString = szConnString + "database=master;";
szConnString = szConnString + "Integrated security=SSPI";
Hope this helps. Please feel free to let me know if you have any questions
or concerns.
Best regards,
Charles Wang
Microsoft Online Community Support
=====================================================When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
======================================================This posting is provided "AS IS" with no warranties, and confers no rights.
======================================================|||Hi John and Charlies,
The solution from John works but the SSPI doesn't.
As long as one of them works, I am happy. However, I would like to know the
difference between them though.
Thanks for all your helps.
Cheers.
"Charles Wang[MSFT]" <changliw@.online.microsoft.com> wrote in message
news:XyodACw4HHA.4200@.TK2MSFTNGHUB02.phx.gbl...
> Hi Light,
> You may try John's suggestion first. Also, I would like to know:
> What is the result if you change your code for windows authentication to
> the following code:
> szConnString = szConnString + "database=master;";
> szConnString = szConnString + "Integrated security=SSPI";
> Hope this helps. Please feel free to let me know if you have any questions
> or concerns.
> Best regards,
> Charles Wang
> Microsoft Online Community Support
> =====================================================> When responding to posts, please "Reply to Group" via
> your newsreader so that others may learn and benefit
> from this issue.
> ======================================================> This posting is provided "AS IS" with no warranties, and confers no
> rights.
> ======================================================>|||Hi Light,
After I dicussed this issue with an ADO expert, this issue was related to
the driver option specified in your connection string. ODBC driver does not
recognize "integrated security" option.
If you use SQL OLEDB provider for the connection string
"Provider=sqloledb;server=CharlesXP;database=Test;Integrated
security=SSPI", it will work fine.
You may refer to:
ADO Connection Strings
http://www.codeproject.com/database/connectionstrings.asp
If you have any other questions or concerns, please feel free to let me
now. Have a nice day!
Best regards,
Charles Wang
Microsoft Online Community Support
======================================================When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
======================================================This posting is provided "AS IS" with no warranties, and confers no rights.
======================================================|||Thanks Charlies.
This is nice info to have.
"Charles Wang[MSFT]" <changliw@.online.microsoft.com> wrote in message
news:6WMHNf04HHA.4200@.TK2MSFTNGHUB02.phx.gbl...
> Hi Light,
> After I dicussed this issue with an ADO expert, this issue was related to
> the driver option specified in your connection string. ODBC driver does
> not
> recognize "integrated security" option.
> If you use SQL OLEDB provider for the connection string
> "Provider=sqloledb;server=CharlesXP;database=Test;Integrated
> security=SSPI", it will work fine.
> You may refer to:
> ADO Connection Strings
> http://www.codeproject.com/database/connectionstrings.asp
> If you have any other questions or concerns, please feel free to let me
> now. Have a nice day!
> Best regards,
> Charles Wang
> Microsoft Online Community Support
> ======================================================> When responding to posts, please "Reply to Group" via
> your newsreader so that others may learn and benefit
> from this issue.
> ======================================================> This posting is provided "AS IS" with no warranties, and confers no
> rights.
> ======================================================>|||Hi Light,
I am glad to hear that the suggestions are helpful. If you have any other
qeustions or concerns, please feel free to let us know.
Have a great day!
Best regards,
Charles Wang
Microsoft Online Community Support
=====================================================When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
======================================================This posting is provided "AS IS" with no warranties, and confers no rights.
======================================================
Sunday, March 11, 2012
Connection for windows authorization
Labels:
adodb,
authorization,
connection,
connects,
database,
microsoft,
mysql,
odbc,
oracle,
padoconnobj,
script,
server,
shown,
snippet,
sql,
szadoconnobjid,
windows
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment