INFO: ADO 2.0 Command Object ConnectionString Property Changes

ID: Q192227


The information in this article applies to:
  • Microsoft Data Access Components version 2.0
  • Microsoft Internet Information Server versions 4.0, 5.0
  • Active Server Pages


SUMMARY

Active Server Pages (ASP) applications written with ActiveX Data Objects (ADO) 1.x, that passed the ADO ConnectionString property using either HTTP POST or GET, may fail using ADO 2.0.


MORE INFORMATION

ADO 2.0 returns the ConnectionString with the "Extended Properties" argument in double-quotes. Passing this value to an HTML property may result in the ConnectionString value being truncated at the first double- quote encountered.

An example of the ConnectionString property returned using ADO 2.0 follows:


   Provider=MSDASQL.1;Data Source=test;Connect Timeout=15;
   Extended Properties="DSN=test;DBQ=C:\Data\MyData.mdb;
   DriverId=25;FIL=MS Access;MaxBufferSize=512;PageTimeout=5;";
   Locale Identifier=1033 


To resolve this issue, replace the double quotes with the HTML variable """. This can be accomplished using the Server.HTMLEncode() in an Active Server Page.

WARNING! The following sample is intended only as an example. Including an ODBC connect string in HTML source could present a breach in security by exposing userids, passwords and the location of data in clear text and is not a recommended practice.

Sample Code


   <%@ LANGUAGE="VBScript"%>
   <%
   Set objConn = Server.CreateObject("ADODB.Connection")
   objConn.Open "MyConnectString"
   %>

   <form method=post action=myasp.asp>

   <input type=hidden name=txtConnString
   value="<%=Server.HTMLEncode(objConn.ConnectionString)%>">

   <input type=submit value=" Go! ">
   </form> 

Additional query words:

Keywords : kbADO kbADO200 kbASP kbDatabase kbDSupport kbiis400 kbiis500
Version : WINDOWS:2.0; winnt:4.0,5.0
Platform : WINDOWS winnt
Issue type : kbinfo


Last Reviewed: December 8, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.