<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Data Access blog : SQL Native Client</title><link>http://blogs.msdn.com/dataaccess/archive/category/9952.aspx</link><description>Discussion related to things pertaining to the SQL Native Client.</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Quick update re: Data Access blog.</title><link>http://blogs.msdn.com/dataaccess/archive/2006/07/11/662727.aspx</link><pubDate>Wed, 12 Jul 2006 00:57:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:662727</guid><dc:creator>alexbarn</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/dataaccess/comments/662727.aspx</comments><wfw:commentRss>http://blogs.msdn.com/dataaccess/commentrss.aspx?PostID=662727</wfw:commentRss><description>&lt;P&gt;We're putting this blog (Data Access blog) into suspended animation. That doesn't mean we will stop blogging about ADO.NET and data access stuff, or that we'll take down published posts or comments here - it's just means we'll carry on blogging about ADO.NET (current and future releases including info on ADO.NET Entity Framework, EDM, LINQ to Entities, etc) at our shiny new &lt;A href="http://blogs.msdn.com/adonet/"&gt;ADO.NET blog&lt;/A&gt;&amp;nbsp;and blog&amp;nbsp;about other data access technology related posts at our other team blogs (see below).&lt;/P&gt;
&lt;P&gt;If you are subscribed to this blog's feed (there are quite a few of you!), please update you reader / aggregator so it points to the new ADO.NET blog's &lt;A href="http://blogs.msdn.com/adonet/rss.xml"&gt;RSS feed&lt;/A&gt; or &lt;A href="http://blogs.msdn.com/adonet/atom.xml"&gt;Atom feed&lt;/A&gt;. We can't automagically redirect you, so sorry for the hassle here.&lt;/P&gt;
&lt;P&gt;Comments on this &lt;A href="http://blogs.msdn.com/dataaccess/"&gt;blogs.msdn/com/dataaccess blog&lt;/A&gt; will be closed, but we have re-published this blog's June and July posts over to the new blog, so you can &lt;A href="http://blogs.msdn.com/dataaccess/"&gt;comment there&lt;/A&gt; if you like.&lt;/P&gt;
&lt;P&gt;In case you are wondering, here's run down of the various blogs run by the Data Programmability teams:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/data/"&gt;The Data Programmability team blog&lt;/A&gt;&amp;nbsp;(more about data access in general, rather than about a specific technology) 
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/sql_protocols"&gt;SQL Protocols team blog&lt;/A&gt;&amp;nbsp;(d&lt;SPAN style="COLOR: #000000"&gt;iscussions related to Microsoft's SQL Server Protocols - Netlibs, TDS and (new for SQL 2005) SOAP. Topics include connections and SQL connectivity)&lt;/SPAN&gt; 
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/xmlteam/"&gt;XML team blog&lt;/A&gt;&amp;nbsp;(covers XQuery, XPath, SQLXML, XML Editor, XSLT, XSD, XLinq (LINQ to XML) and more XML goodness) 
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/adonet/"&gt;ADO.NET team blog&lt;/A&gt;&amp;nbsp;(ADO.NET and System.Data namepace, posts on current and future releases including info on ADO.NET Entity Framework, EDM, LINQ to Entities, etc)&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Also,&amp;nbsp;check out&amp;nbsp;the &lt;A href="http://msdn.microsoft.com/data/"&gt;MSDN Data Access&lt;/A&gt;&amp;nbsp;and &lt;A href="http://msdn.microsoft.com/xml/"&gt;MSDN XML&lt;/A&gt; Developer Centers.&lt;/P&gt;
&lt;P&gt;Hope to see you there!&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=662727" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/dataaccess/archive/tags/ADO.Net/default.aspx">ADO.Net</category><category domain="http://blogs.msdn.com/dataaccess/archive/tags/SQL+Native+Client/default.aspx">SQL Native Client</category><category domain="http://blogs.msdn.com/dataaccess/archive/tags/Misc/default.aspx">Misc</category><category domain="http://blogs.msdn.com/dataaccess/archive/tags/ADO/default.aspx">ADO</category><category domain="http://blogs.msdn.com/dataaccess/archive/tags/PDC-2005/default.aspx">PDC-2005</category><category domain="http://blogs.msdn.com/dataaccess/archive/tags/JDBC/default.aspx">JDBC</category><category domain="http://blogs.msdn.com/dataaccess/archive/tags/LINQ/default.aspx">LINQ</category></item><item><title>Developers! - Express contest - win $10K </title><link>http://blogs.msdn.com/dataaccess/archive/2006/03/14/551390.aspx</link><pubDate>Tue, 14 Mar 2006 21:45:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:551390</guid><dc:creator>alexbarn</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/dataaccess/comments/551390.aspx</comments><wfw:commentRss>http://blogs.msdn.com/dataaccess/commentrss.aspx?PostID=551390</wfw:commentRss><description>&lt;P&gt;A new &lt;EM&gt;worldwide&lt;/EM&gt; contest for developers &lt;A href="http://www.madeinexpresscontest.com/"&gt;has been launched&lt;/A&gt; by the folks at Visual Studio Express and SQL Server Express.&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;P&gt;&lt;A title="photo sharing" href="http://www.madeinexpresscontest.com/"&gt;&lt;IMG alt="Is this pic corny enough for you?" src="http://static.flickr.com/26/112499704_878d26b49f_m.jpg" border=0&gt;&lt;/A&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Here's&amp;nbsp;how it goes:&amp;nbsp;you think of something cool using &lt;A href="http://msdn.microsoft.com/vstudio/express/"&gt;Visual Studio Express&lt;/A&gt; and &lt;A href="http://msdn.microsoft.com/vstudio/express/sql/"&gt;SQL Server Express&lt;/A&gt;. It could be desktop app, a web app, a mobile app, whatever.&amp;nbsp; Then you submit your cool&amp;nbsp;idea &lt;A href="http://www.madeinexpresscontest.com/entry.asp"&gt;here&lt;/A&gt;. &lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;P&gt;&lt;A title="View the offical Made in Express Contest rules." href="http://www.madeinexpresscontest.com/rules.asp"&gt;&lt;IMG height=471 alt="How the 'Made In Express' contest works and when." src="http://www.madeinexpresscontest.com/images/how-it-works.jpg" width=434 border=0&gt;&lt;/A&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Once the finalists are picked, &lt;EM&gt;then you&lt;/EM&gt; build. The top prize is&amp;nbsp;$10,000 (USD)&amp;nbsp;in cash, another winner will win $1,000 in cash, and all 12 finalists who complete their project will receive $250 in Amazon gift certificates.&lt;/P&gt;
&lt;P&gt;There are three judges. Microsoft's &lt;A href="http://scobleizer.wordpress.com/"&gt;Robert Scoble&lt;/A&gt;, MAKE's &lt;A href="http://makezine.com/blog/"&gt;Philip Torrone&lt;/A&gt; and a &lt;A href="http://www.madeinexpresscontest.com/judges.asp"&gt;'Mystery Judge'&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.madeinexpresscontest.com/"&gt;Here's the contest site&lt;/A&gt;....good luck!&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=551390" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/dataaccess/archive/tags/ADO.Net/default.aspx">ADO.Net</category><category domain="http://blogs.msdn.com/dataaccess/archive/tags/SQL+Native+Client/default.aspx">SQL Native Client</category><category domain="http://blogs.msdn.com/dataaccess/archive/tags/Misc/default.aspx">Misc</category><category domain="http://blogs.msdn.com/dataaccess/archive/tags/ADO/default.aspx">ADO</category><category domain="http://blogs.msdn.com/dataaccess/archive/tags/JDBC/default.aspx">JDBC</category><category domain="http://blogs.msdn.com/dataaccess/archive/tags/LINQ/default.aspx">LINQ</category></item><item><title>10 Mistakes Developers Make With Databases</title><link>http://blogs.msdn.com/dataaccess/archive/2006/03/06/544864.aspx</link><pubDate>Tue, 07 Mar 2006 02:01:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:544864</guid><dc:creator>alexbarn</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/dataaccess/comments/544864.aspx</comments><wfw:commentRss>http://blogs.msdn.com/dataaccess/commentrss.aspx?PostID=544864</wfw:commentRss><description>&lt;P&gt;A new article&amp;nbsp;published at Developer.com is worth checking out:&amp;nbsp;&lt;A href="http://www.developer.com/db/article.php/3589351"&gt;Ten of the Biggest Mistakes Developers Make With Databases&lt;/A&gt;.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=544864" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/dataaccess/archive/tags/ADO.Net/default.aspx">ADO.Net</category><category domain="http://blogs.msdn.com/dataaccess/archive/tags/SQL+Native+Client/default.aspx">SQL Native Client</category><category domain="http://blogs.msdn.com/dataaccess/archive/tags/Misc/default.aspx">Misc</category><category domain="http://blogs.msdn.com/dataaccess/archive/tags/ADO/default.aspx">ADO</category><category domain="http://blogs.msdn.com/dataaccess/archive/tags/JDBC/default.aspx">JDBC</category><category domain="http://blogs.msdn.com/dataaccess/archive/tags/LINQ/default.aspx">LINQ</category></item><item><title>Using MARS with SQL Native Client [Chris Lee]</title><link>http://blogs.msdn.com/dataaccess/archive/2005/08/02/446894.aspx</link><pubDate>Wed, 03 Aug 2005 01:53:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:446894</guid><dc:creator>DataWorksBlog</dc:creator><slash:comments>10</slash:comments><comments>http://blogs.msdn.com/dataaccess/comments/446894.aspx</comments><wfw:commentRss>http://blogs.msdn.com/dataaccess/commentrss.aspx?PostID=446894</wfw:commentRss><description>&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;As stated in &lt;a href="http://blogs.msdn.com/dataaccess/archive/2005/07/29/445147.aspx"&gt;my previous post&lt;/A&gt;, the majority of new features available through SQL Native Client are accessed by connection or statement properties. MARS is about the simplest new feature to use in SQL Server 2005, and possibly the one we’ve all been waiting for the longest, so it’s a good candidate for your first excursion into the new features available with SQL Native Client.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;MARS lets an application perform multiple operations on a single connection even if there are default result sets open on the connection. Prior to MARS, ADO and SQLOLEDB applications would (under default conditions) use implicit multiple connections and ODBC applications would get ‘connection busy’ errors.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;&lt;FONT color=#0000ff&gt;&lt;STRONG&gt;Pre-MARS behavior&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR&gt;Let’s look at MARS using ADO for simplicity (I’ll mention how to enable MARS with ODBC or OLE DB at the end of this post, but don’t skip there just yet as most of what follows is still going to be useful to you even if you’re not using ADO). Try executing the following code (which assumes you have a SQL Server instance called SQL2K5 with the AdventureWorks demo database available on your local machine). This is just ‘nonsense’ code that just opens a default result set and then opens another result set using the same query multiple times, to make a point. The extension of the point it makes to your own applications shouldn’t be hard to grasp.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" color=#000080 size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim i As Integer&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim cn As ADODB.Connection&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim qryCustomers1 As ADODB.Command&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim qryCustomers2 As ADODB.Command&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim rsCustomers1 As ADODB.Recordset&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim rsCustomers2 As ADODB.Recordset&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set cn = New ADODB.Connection&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cn.Open ("Provider=sqlncli;Data Source=.\SQL2K5" &amp;amp; _&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ";Database=AdventureWorks;Integrated Security=SSPI;")&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set qryCustomers1 = New ADODB.Command&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set qryCustomers1.ActiveConnection = cn&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; qryCustomers1.CommandText = "SELECT CustomerID" &amp;amp; _&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; " FROM Sales.Customer" &amp;amp; _&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; " WHERE CustomerID=1" &amp;amp; _&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; " ORDER BY CustomerID"&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set qryCustomers2 = New ADODB.Command&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set qryCustomers2.ActiveConnection = cn&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; qryCustomers2.CommandText = qryCustomers1.CommandText&lt;BR&gt;&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set rsCustomers1 = qryCustomers1.Execute&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; For i = 1 To 3&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set rsCustomers2 = qryCustomers2.Execute&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rsCustomers2.Close&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Next i&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rsCustomers1.Close&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cn.Close&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;If you take a default SQL Server Profiler trace you’ll see something like this:&lt;/FONT&gt;&lt;/P&gt;&lt;IMG title=ProfilerTrace alt=ProfilerTrace_PreMARS.jpg src="http://sushil.members.winisp.net/preMARS.jpg"&gt; 
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;The second result set is using a new connection each time it is opened. This clearly has some overhead (and it turns out that the additional connections aren’t pooled, so the overhead is for a full server connection network protocol exchange each time). This is the default behavior for SQLOLEDB and SQL Native Client (OLE DB) – a new implicit connection is spawned when the main connection is busy with a default result set. You can prevent multiple implicit connections being spawned by changing the connection lines to&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" color=#000080 size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cn.Open ("Provider=sqlncli;Data Source=.\SQL2K5;Database=AdventureWorks;Integrated Security=SSPI;")&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cn.Properties("Multiple Connections") = False&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;The effect of this is&amp;nbsp;as follows. This is similar to ODBC where multiple implicit connections aren’t used and the application gets a ‘connection busy’ error.&amp;nbsp;&amp;nbsp;&lt;BR&gt;&amp;nbsp;&lt;/FONT&gt;&lt;IMG title=ErrorWithoutUsingMARS alt=PreMARSError.jpg src="http://sushil.members.winisp.net/marsError.jpg"&gt; &lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;&lt;STRONG&gt;&lt;FONT color=#0000ff&gt;Behavior with MARS&lt;BR&gt;&lt;/FONT&gt;&lt;/STRONG&gt;Now we’re ready for MARS. &lt;FONT face=Tahoma size=2&gt;In addition to&amp;nbsp;providing a great deal more convenience to the programmer, MARS can reduce server overhead too. &lt;/FONT&gt;Change the connection string to:&lt;/FONT&gt;&lt;FONT face=Tahoma size=2&gt;&amp;nbsp;&lt;FONT face="Courier New" color=#000080&gt;cn.Open ("Provider=sqlncli;Data Source=.\SQL2K5;MARS Connection=True;Database=AdventureWorks;Integrated Security=SSPI;")&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;And the code works again, but now the Profiler trace looks like this:&lt;/FONT&gt;&lt;/P&gt;&lt;IMG title=ProfilerTrace alt=ProfilerTrace_PreMARS.jpg src="http://sushil.members.winisp.net/postMARS.jpg"&gt; 
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;&lt;STRONG&gt;&lt;FONT color=#0000ff&gt;Is MARS all good news, or is there any downside?&lt;/FONT&gt;&lt;/STRONG&gt; Well, mostly MARS &lt;STRONG&gt;is&lt;/STRONG&gt; good news. The downsides are twofold. First, existing code optimized to run in the non-MARS world may show a slight performance dip when run un-modified with MARS. Default result sets make &lt;STRONG&gt;very&lt;/STRONG&gt; efficient use of network resources and adding the MARS capability incurs some additional network overhead. The message here is “if it ain’t broke don’t fix it”, or – as with any feature – you need to design your code to make best use of MARS.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;This brings us to the second caveat when using MARS – don’t try to get too smart. With MARS you can send multiple multi-statement batches to the server. The server will interleave execution of such batches, which means that if the batches change server state via SET or USE statements, for example, or use TSQL transaction management statements (BEGIN TRAN, COMMIT, ROLLBACK), both you and the server can get confused about what your actual intent is. The outcome may be an error, or it may be that the application doesn’t behave as you expected it to. It is because of these potential difficulties when MARS is ‘over used’, that we decided to turn it off by default rather than have it enabled by default, as it was for Beta 2.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;Without MARS you can only execute one multi-statement batch at a time, which results in completely predictable performance. Stay with this model with MARS – but of course with the relaxation that you can execute multiple single statement queries and have their result sets pending at the point at which you execute your multi-statement batch – and you’ll stay out of trouble. This model is all that most people want and expect to do with MARS anyway.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;It’s likely that the first thing you’ll want to try with MARS is convert server cursors to default result sets. Is this the right thing to do? If the result set is fairly small, or will be consumed in its entirety fairly quickly and you don’t require locking on rows in the result set and you haven’t optimized your code to use block fetches, then conversion to a default result set with MARS will be beneficial. If you’re not going to process all the rows in a result set, or the result set is very large and will not be read quickly, or you need locking or scrolling, then you should stay with a server cursor.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;There are some other considerations you need to take into account. Firstly, you can’t begin a transaction when you have a default result set open. Secondly, if you commit or rollback a transaction any open default result sets become unavailable (attempts to use them result in errors). These restrictions are the same whether you use MARS or not, although the error messages are different in some cases. If you need ‘Preserve On Commit’ behavior, then you &lt;STRONG&gt;must&lt;/STRONG&gt; use a server cursor. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma color=#0000ff size=2&gt;&lt;STRONG&gt;Using MARS from ODBC and OLE DB&lt;/STRONG&gt;&lt;FONT face="Courier New" color=#000080&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face=Tahoma size=2&gt;To use MARS with ODBC the connection string addition is “MARS_Connection=yes”, or you can a connection attribute as follows:&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT face="Courier New" color=#000080&gt;SQLSetConnectAttr(hdbc, SQL_COPT_SS_MARS_ENABLED,SQL_MARS_ENABLED_YES, SQL_IS_UINTEGER);&lt;BR&gt;&lt;/FONT&gt;before calling SQLDriverConnect or SQLBrowseConnect. With OLE DB, the provider string addition for&lt;FONT face="Courier New" color=#000080&gt; IDBInitialize::Initialize&lt;/FONT&gt; is “MarsConn=yes”, or “MARS Connection=true” if you use an initialization string with &lt;FONT face="Courier New" color=#000080&gt;IDataInitialize::GetDataSource&lt;/FONT&gt;. You can also enable MARS programmatically as follows:&lt;/FONT&gt;&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;&lt;FONT face="Courier New" color=#000080&gt;IDBInitialize *pIDBInitialize = NULL;&lt;BR&gt;IDBProperties *pIDBProperties = NULL;&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" color=#000080 size=2&gt;// Create the data source object.&lt;BR&gt;hr = CoCreateInstance(CLSID_SQLNCLI, NULL, CLSCTX_INPROC_SERVER,IID_IDBInitialize,&amp;nbsp;(void**)&amp;amp;pIDBInitialize);&lt;BR&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" color=#000080 size=2&gt;hr = pIDBInitialize-&amp;gt;QueryInterface(IID_IDBProperties, (void**)&amp;amp;pIDBProperties);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" color=#000080 size=2&gt;// Set the MARS property.&lt;BR&gt;DBPROP rgPropMARS;&lt;BR&gt;IDBProperties &lt;/FONT&gt;&lt;FONT face="Courier New" color=#000080 size=2&gt;rgPropMARS.dwPropertyID = SSPROP_INIT_MARSCONNECTION;&lt;BR&gt;rgPropMARS.dwOptions = DBPROPOPTIONS_REQUIRED;&lt;BR&gt;rgPropMARS.dwStatus = DBPROPSTATUS_OK;&lt;BR&gt;rgPropMARS.colid = DB_NULLID;&lt;BR&gt;V_VT(&amp;amp;(rgPropMARS.vValue)) = VT_BOOL;&lt;BR&gt;V_BOOL(&amp;amp;(rgPropMARS.vValue)) = VARIANT_TRUE;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" color=#000080 size=2&gt;// Create the structure containing the properties.&lt;BR&gt;DBPROPSET PropSet;&lt;BR&gt;PropSet.rgProperties = &amp;amp;rgPropMARS;&lt;BR&gt;PropSet.cProperties = 1;&lt;BR&gt;PropSet.guidPropertySet = DBPROPSET_SQLSERVERDBINIT;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" color=#000080 size=2&gt;// Get an IDBProperties pointer and set the initialization properties.&lt;BR&gt;pIDBProperties-&amp;gt;SetProperties(1, &amp;amp;PropSet);&lt;BR&gt;pIDBProperties-&amp;gt;Release();&lt;BR&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" color=#000080 size=2&gt;// Initialize the data source object.&lt;BR&gt;hr = pIDBInitialize-&amp;gt;Initialize();&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT face=Tahoma color=#0000ff size=2&gt;&lt;STRONG&gt;Conclusion&lt;/STRONG&gt;&lt;FONT face="Courier New" color=#000080&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face=Tahoma size=2&gt;MARS is a great new feature that fosters a more natural programming style when working with SQL Server 2005, especially if you’ve ever worked with other databases. With ADO and OLE DB your applications will probably require fewer server connections. MARS will be problem free when used sensibly, but you still need to give some thought to the choice between default result sets and server cursors, although you have more flexibility than before.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma color=#0000ff size=2&gt;&lt;STRONG&gt;Chris Lee&lt;/STRONG&gt;&lt;BR&gt;Program Manager, DataWorks&lt;BR&gt;&lt;FONT face=Tahoma color=#000080 size=1&gt;Disclaimer: This posting is provided "AS IS" with no warranties, and confers &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=446894" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/dataaccess/archive/tags/SQL+Native+Client/default.aspx">SQL Native Client</category></item><item><title>Getting started with SQL Native Client [Chris Lee]</title><link>http://blogs.msdn.com/dataaccess/archive/2005/07/29/445147.aspx</link><pubDate>Sat, 30 Jul 2005 00:31:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:445147</guid><dc:creator>DataWorksBlog</dc:creator><slash:comments>6</slash:comments><comments>http://blogs.msdn.com/dataaccess/comments/445147.aspx</comments><wfw:commentRss>http://blogs.msdn.com/dataaccess/commentrss.aspx?PostID=445147</wfw:commentRss><description>&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;As Acey Bunch &lt;a href="http://blogs.msdn.com/dataaccess/archive/2005/04/26/412161.aspx"&gt;explained in April&lt;/A&gt;, SQL Native Client meets the needs of developers wanting to take advantage of new features in SQL Server 2005 from ADO, ODBC and OLE DB applications. For those of you who haven’t looked at SQL Native Client yet we now need to start the education process of how to use it. The good news is that it’s very simple. We have implemented a very small number of new interfaces for OleDb, but most new features are implemented via connection or statement attributes, which you already know how to use. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;I’ll start at a very basic level and talk about how to convert existing applications to use SQL Native Client. This comes in three stages: first getting existing code running; second, preparing to exploit new features; third, using new features. In this post I’ll deal with the first two of these. The third will be covered in my next post, using Multiple Active Result Sets (MARS) as an example. If you have SQL Server 2005 installed on your machine, SQL Native Client is already installed. If not, SQLNCLI.msi is included with the SQL Server 2005 distribution, but isn’t copied when SQL Server 2005 is installed, so just copy it from the distribution in the \Setup folder.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;&lt;FONT color=#0000ff&gt;&lt;STRONG&gt;&lt;U&gt;Stage 1:Getting existing code running&lt;/U&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR&gt;&lt;STRONG&gt;&lt;U&gt;For ADO&lt;/U&gt;&lt;/STRONG&gt; you change your connection string to use SQLNCLI as the provider, and add a keyword to enable SQL Server 2000 data type compatibility, so&lt;BR&gt;&lt;FONT style="BACKGROUND-COLOR: #ffffff" face="Courier New" color=#000080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;“ …;Provider=SQLOLEDB;…”&lt;/FONT&gt;&lt;BR&gt;becomes&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT face="Courier New" color=#000080&gt;“…;Provider=SQLNCLI;DataTypeCompatibility=80;…”&lt;/FONT&gt;&lt;BR&gt;ADO is a generic data access API that is now part of the Windows Platform and is not part of SQL Native Client, so the ADO on your machine did not change when you installed SQL Native Client. Therefore, it doesn’t have any specific knowledge of SQL Server in general, much less the new datatypes introduced for SQL Server 2005. For this reason, when using ADO we have to tell SQL Native Client to map new SQL Server 2005 data types to data types that ADO does understand. I’ll explain this in a later article, for now accept that we need this, and that it doesn’t get in the way of using other new features of SQL Server 2005.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;&lt;STRONG&gt;&lt;U&gt;For ODBC&lt;/U&gt;&lt;/STRONG&gt; you change the driver name from ‘SQL Server’ to ‘SQL Native Client’. If your application uses a DSN you need to create a new DSN and select ‘SQL Native Client’ as the driver. If you use DSN-less connections just update the connection string in your application.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;&lt;STRONG&gt;&lt;U&gt;For OLE DB&lt;/U&gt;&lt;/STRONG&gt; you simply change the provider name from ‘SQLOLEDB’ to ‘SQLNCLI’, or use CLSID_SQLNCLI instead of CLSID_SQLOLEDB.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;&lt;STRONG&gt;&lt;U&gt;&lt;FONT color=#0000ff&gt;Stage 2: Preparing to use new features&lt;BR&gt;&lt;/FONT&gt;For ADO:&lt;/U&gt;&lt;/STRONG&gt; If you’re using ADO, you’re already good to go. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;ODBC and OLE DB applications need to use sqlncli.h to gain access to new features. You also need to be using Visual Studio.Net. Sqlncli.h is a new common header file for both ODBC and OLE DB and is typically installed to C:\Program Files\Microsoft SQL Server\90\SDK\Include. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;&lt;STRONG&gt;&lt;U&gt;For ODBC&lt;/U&gt;&lt;/STRONG&gt; sqlncli.h is a straight replacement for odbcss.h. If you’re using bcp API calls alongside ODBC calls then you need to link with sqlncli.lib instead of odbcbcp.lib. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;&lt;STRONG&gt;&lt;U&gt;For OLE DB&lt;/U&gt;&lt;/STRONG&gt; you can add the #include for sqlncli.h after the #include for sqloledb.h if you need to use both old and new providers (sqlncli.h doesn’t contain the CLSIDs for SQLOLEDB), or you can replace the #include for sqloledb.h with the #include for sqlncli.h if you don’t need the old CLSIDs. If you need both headers, the #include for sqloledb.h must come first.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;Since sqlncli contains symbols for both ODBC and OLE DB, there’s a chance you may get a name clash between one of your own symbols and a symbol defined for use by the ‘other’ API (the one you’re not going to be using). In this case you can add a #define to get rid of the symbols for the API you don’t need. If you’re using OLE DB you #define _SQLNCLI_OLEDB_ and if you’re using ODBC you #define _SQLNCLI_ODBC_.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;&lt;U&gt;&lt;FONT color=#0000ff&gt;&lt;STRONG&gt;Next steps …&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR&gt;&lt;/U&gt;You’re now prepared to start using the new features of SQL Server 2005 available with SQL Native Client. Consult SQL Native Client Programming in SQL Server Programming Refernce in Books Online for details of these features. The documentation for SQL Native Client has been updated quite a lot recently, so you need to use the latest build available to you. Most of the new features are very simple to program and are controlled by connection or statement properties. In my next post I’ll take a look at Multiple Active Result Sets (MARS).&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#0000ff&gt;&lt;FONT face=Tahoma size=2&gt;&lt;STRONG&gt;Chris Lee&lt;BR&gt;&lt;/STRONG&gt;Program Manager, DataWorks&lt;/FONT&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT face=Tahoma color=#000080 size=1&gt;Disclaimer: This posting is provided "AS IS" with no warranties, and confers &lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=445147" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/dataaccess/archive/tags/SQL+Native+Client/default.aspx">SQL Native Client</category></item></channel></rss>