<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Visual Basic World</title>
	<atom:link href="http://vbworld.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://vbworld.wordpress.com</link>
	<description>Just another Visual Basic weblog</description>
	<lastBuildDate>Sun, 12 Sep 2010 08:04:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='vbworld.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Visual Basic World</title>
		<link>http://vbworld.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://vbworld.wordpress.com/osd.xml" title="Visual Basic World" />
	<atom:link rel='hub' href='http://vbworld.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Visual Studio 2005 Cookbook &#8211; Database, Reading an XML File into In-Memory Data Tables</title>
		<link>http://vbworld.wordpress.com/2008/07/09/visual-studio-2005-cookbook-database-reading-an-xml-file-into-in-memory-data-tables/</link>
		<comments>http://vbworld.wordpress.com/2008/07/09/visual-studio-2005-cookbook-database-reading-an-xml-file-into-in-memory-data-tables/#comments</comments>
		<pubDate>Wed, 09 Jul 2008 10:23:03 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[database]]></category>
		<category><![CDATA[programing]]></category>
		<category><![CDATA[vb.net]]></category>
		<category><![CDATA[Data]]></category>
		<category><![CDATA[Data Formats]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Markup Languages]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Validation]]></category>
		<category><![CDATA[visual basic 2005]]></category>
		<category><![CDATA[visual basic.net]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[XML schema]]></category>

		<guid isPermaLink="false">http://vbworld.wordpress.com/?p=22</guid>
		<description><![CDATA[Recipe 13.10. Reading an XML File into In-Memory Data Tables Problem You previously exported a DataSet to an XML file, and now you need to get it back. Solution Use the DataSet object’s ReadXML() method to restore data from a previously generated XML export. Discussion Recipe 13.9 exports some XML and a related schema for [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vbworld.wordpress.com&amp;blog=3603633&amp;post=22&amp;subd=vbworld&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h3 class="docSection1Title">Recipe 13.10. Reading an <a class="zem_slink" title="XML" rel="wikipedia" href="http://en.wikipedia.org/wiki/XML">XML</a> File  into In-Memory Data Tables</h3>
<p><a name="vb2005ckbk-CHP-13-SECT-10.1"></a></p>
<h4 class="docSection2Title">Problem</h4>
<p class="docText">You previously exported a <tt>DataSet</tt> to an XML file, and  now you need to get it back.</p>
<p><a name="vb2005ckbk-CHP-13-SECT-10.2"></a></p>
<h4 class="docSection2Title">Solution</h4>
<p class="docText">Use the <tt>DataSet</tt> object’s <tt>ReadXML()</tt> method to  restore data from a previously generated XML export.</p>
<p><a name="vb2005ckbk-CHP-13-SECT-10.3"></a></p>
<h4 class="docSection2Title">Discussion</h4>
<p class="docText"><a class="docLink" href="http://indragds.890m.com/vbworld/wp-admin/vb2005ckbk-CHP-13-SECT-9.html#vb2005ckbk-CHP-13-SECT-9">Recipe 13.9</a> exports some XML and a related <a class="zem_slink" title="XML schema" rel="wikipedia" href="http://en.wikipedia.org/wiki/XML_schema">schema</a> for a table with state-specific  information. To read it back into a <tt>DataSet</tt> object, use the following  code:</p>
<pre>	Dim stateSet As New Data.DataSet
	stateSet.ReadXmlSchema("c:StateSchema.xml")
	stateSet.ReadXml("c:StateInfo.xml")</pre>
<p>You do not need to import a previously saved schema into a  <tt>DataSet</tt> before retrieving the related data, but it helps. Without the  schema, <a href="http://indragds.890m.com/vbworld/?p=20" target="_self"></a></p>
<p><strong><a href="http://duniavb.blogspot.com/2010/09/database-reading-xml-file-into-in.html" target="_blank">Read More &gt;&gt;</a></strong></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/vbworld.wordpress.com/22/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/vbworld.wordpress.com/22/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vbworld.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vbworld.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vbworld.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vbworld.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vbworld.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vbworld.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vbworld.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vbworld.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vbworld.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vbworld.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vbworld.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vbworld.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vbworld.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vbworld.wordpress.com/22/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vbworld.wordpress.com&amp;blog=3603633&amp;post=22&amp;subd=vbworld&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://vbworld.wordpress.com/2008/07/09/visual-studio-2005-cookbook-database-reading-an-xml-file-into-in-memory-data-tables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/ba8318d092db6de964aa444094c5fd10?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Admin</media:title>
		</media:content>
	</item>
		<item>
		<title>Visual Studio 2005 Cookbook &#8211; Database, Writing In-Memory Data Tables to an XML File</title>
		<link>http://vbworld.wordpress.com/2008/07/09/visual-studio-2005-cookbook-database-writing-in-memory-data-tables-to-an-xml-file/</link>
		<comments>http://vbworld.wordpress.com/2008/07/09/visual-studio-2005-cookbook-database-writing-in-memory-data-tables-to-an-xml-file/#comments</comments>
		<pubDate>Wed, 09 Jul 2008 10:21:13 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[database]]></category>
		<category><![CDATA[programing]]></category>
		<category><![CDATA[vb.net]]></category>
		<category><![CDATA[Data]]></category>
		<category><![CDATA[Data Formats]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Markup language]]></category>
		<category><![CDATA[Open source]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[vb]]></category>
		<category><![CDATA[visual basic.net vb.net]]></category>
		<category><![CDATA[Washington]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://vbworld.wordpress.com/?p=21</guid>
		<description><![CDATA[Recipe 13.9. Writing In-Memory Data Tables to an XML File Problem You have some data in a DataSet object, and you would like to export it to an XML file for later reimportation. Solution Use the DataSet’s WriteXML() method to send the DataSet content to the file in a common XML format. Discussion Recipe 13.8 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vbworld.wordpress.com&amp;blog=3603633&amp;post=21&amp;subd=vbworld&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h3 class="docSection1Title">Recipe 13.9. Writing In-Memory Data  Tables to an <a class="zem_slink" title="XML" rel="wikipedia" href="http://en.wikipedia.org/wiki/XML">XML</a> File</h3>
<p><a name="idx-CHP-13-1212"></a><a name="vb2005ckbk-CHP-13-SECT-9.1"></a></p>
<h4 class="docSection2Title">Problem</h4>
<p class="docText">You have some data in a <tt>DataSet</tt> object, and you would  like to export it to an XML file for later reimportation.</p>
<p><a name="vb2005ckbk-CHP-13-SECT-9.2"></a></p>
<h4 class="docSection2Title">Solution</h4>
<p class="docText">Use the <tt>DataSet</tt>’s <tt><a name="idx-CHP-13-1213"></a>WriteXML()</tt> method to send the <tt>DataSet</tt> content to the file in a common XML format.</p>
<p><a name="vb2005ckbk-CHP-13-SECT-9.3"></a></p>
<h4 class="docSection2Title">Discussion</h4>
<p class="docText"><a class="docLink" href="http://indragds.890m.com/vbworld/wp-admin/vb2005ckbk-CHP-13-SECT-8.html#vb2005ckbk-CHP-13-SECT-8">Recipe 13.8</a> builds a <tt>DataTable</tt> object with two state-specific records. The  following code adds that table to a <tt>DataSet</tt> object and writes its  records to an XML file:</p>
<pre>	Dim fullDataSet As New Data.DataSet
	fullDataSet.Tables.Add(stateTable)
	fullDataSet.WriteXml("C:StateInfo.xml")</pre>
<p class="docText">These statements generate the following XML content:</p>
<pre>	&lt;?xml version="1.0" standalone="yes"?&gt;
	&lt;NewDataSet&gt;
	  &lt;UnitedStates&gt;
	    &lt;ShortName&gt;WA&lt;/ShortName&gt;
	    &lt;FullName&gt;Washington&lt;/FullName&gt;
	    &lt;Admission&gt;1889-11-11T00:00:00-08:00&lt;/Admission&gt;
	    &lt;Population&gt;5894121&lt;/Population&gt;
	  &lt;/UnitedStates&gt;
	  &lt;UnitedStates&gt;
	    &lt;ShortName&gt;MT&lt;/ShortName&gt;
	    &lt;FullName&gt;Montana&lt;/FullName&gt;
	    &lt;Admission&gt;1889-11-08T00:00:00-08:00&lt;/Admission&gt;
	    &lt;Population&gt;902195&lt;/Population&gt;
	  &lt;/UnitedStates&gt;
	&lt;/NewDataSet&gt;</pre>
<p>You can also output the XML directly <a href="http://indragds.890m.com/vbworld/?p=19" target="_self"></a></p>
<p><a href="http://duniavb.blogspot.com/2010/09/database-writing-in-memory-data-tables.html" target="_blank"><strong>Read More &gt;&gt;</strong></a></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/vbworld.wordpress.com/21/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/vbworld.wordpress.com/21/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vbworld.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vbworld.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vbworld.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vbworld.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vbworld.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vbworld.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vbworld.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vbworld.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vbworld.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vbworld.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vbworld.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vbworld.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vbworld.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vbworld.wordpress.com/21/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vbworld.wordpress.com&amp;blog=3603633&amp;post=21&amp;subd=vbworld&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://vbworld.wordpress.com/2008/07/09/visual-studio-2005-cookbook-database-writing-in-memory-data-tables-to-an-xml-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/ba8318d092db6de964aa444094c5fd10?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Admin</media:title>
		</media:content>
	</item>
		<item>
		<title>Visual Studio 2005 Cookbook &#8211; Database, Creating In-Memory Data Tables Manually</title>
		<link>http://vbworld.wordpress.com/2008/07/09/visual-studio-2005-cookbook-database-creating-in-memory-data-tables-manually/</link>
		<comments>http://vbworld.wordpress.com/2008/07/09/visual-studio-2005-cookbook-database-creating-in-memory-data-tables-manually/#comments</comments>
		<pubDate>Wed, 09 Jul 2008 10:18:45 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[database]]></category>
		<category><![CDATA[programing]]></category>
		<category><![CDATA[vb.net]]></category>
		<category><![CDATA[ADO]]></category>
		<category><![CDATA[ADO.NET]]></category>
		<category><![CDATA[Data]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[Tables]]></category>
		<category><![CDATA[Unique key]]></category>
		<category><![CDATA[United States]]></category>
		<category><![CDATA[vb]]></category>
		<category><![CDATA[visual basic]]></category>
		<category><![CDATA[visual basic 2005]]></category>
		<category><![CDATA[visual basic.net]]></category>

		<guid isPermaLink="false">http://vbworld.wordpress.com/?p=20</guid>
		<description><![CDATA[Recipe 13.8. Creating In-Memory Data Tables Manually Problem You want to manage some data in a database-table-like fashion, but the source data is not coming from a database, or from anything that looks like a table. Solution Build a DataTable manually, and fill in all the table details and data yourself. Discussion The following code [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vbworld.wordpress.com&amp;blog=3603633&amp;post=20&amp;subd=vbworld&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h3 class="docSection1Title">Recipe 13.8. Creating In-Memory  Data Tables Manually</h3>
<p><a name="idx-CHP-13-1209"></a><a name="vb2005ckbk-CHP-13-SECT-8.1"></a></p>
<h4 class="docSection2Title">Problem</h4>
<p class="docText">You want to manage some data in a <a class="zem_slink" title="Table (database)" rel="wikipedia" href="http://en.wikipedia.org/wiki/Table_%28database%29">database-table</a>-like fashion, but the source data is not coming from a database, or from anything that looks like a table.</p>
<p><a name="vb2005ckbk-CHP-13-SECT-8.2"></a></p>
<h4 class="docSection2Title">Solution</h4>
<p class="docText">Build a <tt>DataTable</tt> manually, and fill in all the table  details and data yourself.</p>
<p><a name="vb2005ckbk-CHP-13-SECT-8.3"></a></p>
<h4 class="docSection2Title">Discussion</h4>
<p class="docText">The following code builds a simple table of state information  and adds two records:</p>
<pre>	Dim stateTable As DataTable = New DataTable("UnitedStates")

	' ----- Use the abbreviation as the primary key.
	Dim priKeyCol(0) As Data.DataColumn
	priKeyCol(0) = stateTable.Columns.Add("ShortName", GetType(String))
	stateTable.PrimaryKey = priKeyCol

	' ----- Add other data columns.
	stateTable.Columns.Add("FullName", GetType(String))
	stateTable.Columns.Add("Admission", GetType(Date))
	stateTable.Columns.Add("Population", GetType(Long))

	' ----- Add a record.
	Dim stateInfo As Data.DataRow = stateTable.NewRow()
	stateInfo!ShortName = "WA"
	stateInfo!FullName = "Washington"
	stateInfo!Admission = #11/11/1889#
	stateInfo!Population = 5894121
	stateTable.Rows.Add(stateInfo)

	' ----- Add another record.
	stateInfo = stateTable.NewRow()
	stateInfo!ShortName = "MT"
	stateInfo!FullName = "Montana"
	stateInfo!Admission = #11/8/1889#
	stateInfo!Population = 902195
	stateTable.Rows.Add(stateInfo)

	' ----- Prove that the data arrived.
	MsgBox(stateTable.Rows.Count)       ' Displays "2"
	MsgBox(stateTable.Rows(0)!FullName) ' Displays "Washington"</pre>
<p><a class="zem_slink" title="ADO.NET" rel="wikipedia" href="http://en.wikipedia.org/wiki/ADO.NET">ADO.NET</a> defines the basic structures for tables, <a href="http://indragds.890m.com/vbworld/?p=18" target="_self"></a></p>
<p><a href="http://duniavb.blogspot.com/2010/09/database-creating-in-memory-data-tables.html"><strong>Read More &gt;&gt;</strong></a></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/vbworld.wordpress.com/20/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/vbworld.wordpress.com/20/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vbworld.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vbworld.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vbworld.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vbworld.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vbworld.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vbworld.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vbworld.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vbworld.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vbworld.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vbworld.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vbworld.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vbworld.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vbworld.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vbworld.wordpress.com/20/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vbworld.wordpress.com&amp;blog=3603633&amp;post=20&amp;subd=vbworld&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://vbworld.wordpress.com/2008/07/09/visual-studio-2005-cookbook-database-creating-in-memory-data-tables-manually/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/ba8318d092db6de964aa444094c5fd10?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Admin</media:title>
		</media:content>
	</item>
		<item>
		<title>Visual Studio 2005 Cookbook &#8211; Database, Storing the Results of a Query in Memory</title>
		<link>http://vbworld.wordpress.com/2008/07/09/visual-studio-2005-cookbook-database-storing-the-results-of-a-query-in-memory/</link>
		<comments>http://vbworld.wordpress.com/2008/07/09/visual-studio-2005-cookbook-database-storing-the-results-of-a-query-in-memory/#comments</comments>
		<pubDate>Wed, 09 Jul 2008 10:11:43 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[database]]></category>
		<category><![CDATA[programing]]></category>
		<category><![CDATA[vb.net]]></category>
		<category><![CDATA[Component Frameworks]]></category>
		<category><![CDATA[Data]]></category>
		<category><![CDATA[Languages]]></category>
		<category><![CDATA[NET]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[vb 2005]]></category>
		<category><![CDATA[visual basic.net]]></category>

		<guid isPermaLink="false">http://vbworld.wordpress.com/?p=19</guid>
		<description><![CDATA[Recipe 13.7. Storing the Results of a Query in Memory Problem While a data reader is fast and convenient, you would like to keep the retrieved data around for a while, even when you are disconnected from the database or other data source. Solution Use the data reader to bring the results into a data [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vbworld.wordpress.com&amp;blog=3603633&amp;post=19&amp;subd=vbworld&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h3 class="docSection1Title">Recipe 13.7. Storing the Results of  a Query in Memory</h3>
<p><a name="idx-CHP-13-1195"></a><a name="vb2005ckbk-CHP-13-SECT-7.1"></a></p>
<h4 class="docSection2Title">Problem</h4>
<p class="docText">While a <a class="zem_slink" title="Data" rel="wikipedia" href="http://en.wikipedia.org/wiki/Data">data</a> reader is fast and convenient, you would like to keep the retrieved data around for a while, even when you are disconnected from the <a class="zem_slink" title="Database" rel="wikipedia" href="http://en.wikipedia.org/wiki/Database">database</a> or other data source.</p>
<p><a name="vb2005ckbk-CHP-13-SECT-7.2"></a></p>
<h4 class="docSection2Title">Solution</h4>
<p class="docText">Use the data reader to bring the results into a <a class="zem_slink" title="Data set" rel="wikipedia" href="http://en.wikipedia.org/wiki/Data_set">data set</a>. The  <tt><a name="idx-CHP-13-1196"></a>DataSet</tt> object represents one or more  <a class="zem_slink" title="In-memory database" rel="wikipedia" href="http://en.wikipedia.org/wiki/In-memory_database">in-memory database</a> tables, each with its records stored in a separate <tt><a name="idx-CHP-13-1197"></a>DataTable</tt> object.</p>
<p><a name="vb2005ckbk-CHP-13-SECT-7.3"></a></p>
<h4 class="docSection2Title">Discussion</h4>
<p class="docText">The following code loads all records from the <tt>Table1</tt> table into a <tt>DataSet</tt> object, creating a <tt>DataTable</tt> object named  <tt>Table1</tt> within that data set:</p>
<pre>	' ----- Connect to the database.
	Dim <a name="idx-CHP-13-1198"></a>
connectionString As String = _
	   “Data Source=MySystemSQLEXPRESS;” &amp; _
	   “Initial Catalog=MyDatabase;Integrated Security=true”
	Dim theDatabase As New SqlClient.SqlConnection(connectionString)
	theDatabase.Open()

	‘ —– Prepare the <a class="zem_slink" title="SQL" rel="wikipedia" href="http://en.wikipedia.org/wiki/SQL">SQL</a> statement for use by the data set.
	Dim sqlStatement As New SqlClient.SqlCommand( _
	   “<a class="zem_slink" title="Select (SQL)" rel="wikipedia" href="http://en.wikipedia.org/wiki/Select_%28SQL%29">SELECT</a> * FROM Table1″, theDatabase)
        <a href="http://duniavb.blogspot.com/2010/09/database-storing-results-of-query-in.html#more" target="_self">Read More &gt;&gt;</a></pre>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/vbworld.wordpress.com/19/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/vbworld.wordpress.com/19/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vbworld.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vbworld.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vbworld.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vbworld.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vbworld.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vbworld.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vbworld.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vbworld.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vbworld.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vbworld.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vbworld.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vbworld.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vbworld.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vbworld.wordpress.com/19/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vbworld.wordpress.com&amp;blog=3603633&amp;post=19&amp;subd=vbworld&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://vbworld.wordpress.com/2008/07/09/visual-studio-2005-cookbook-database-storing-the-results-of-a-query-in-memory/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/ba8318d092db6de964aa444094c5fd10?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Admin</media:title>
		</media:content>
	</item>
		<item>
		<title>Visual Studio 2005 Cookbook &#8211; Database, Using Transactions</title>
		<link>http://vbworld.wordpress.com/2008/07/09/visual-studio-2005-cookbook-database-using-transactions/</link>
		<comments>http://vbworld.wordpress.com/2008/07/09/visual-studio-2005-cookbook-database-using-transactions/#comments</comments>
		<pubDate>Wed, 09 Jul 2008 10:06:44 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[database]]></category>
		<category><![CDATA[programing]]></category>
		<category><![CDATA[vb.net]]></category>
		<category><![CDATA[ADO]]></category>
		<category><![CDATA[ADO.NET]]></category>
		<category><![CDATA[Articles]]></category>
		<category><![CDATA[NET]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[vb 2005]]></category>
		<category><![CDATA[visual basic 2005]]></category>
		<category><![CDATA[visual basic.net]]></category>

		<guid isPermaLink="false">http://vbworld.wordpress.com/?p=18</guid>
		<description><![CDATA[Recipe 13.6. Using Transactions Problem You need to issue multiple database updates in the context of a single, atomic transaction. Solution Use an ADO.NET transaction to envelop the various SQL statements that need to be processed as a unit. Discussion The following block of code connects to a database via ADO.NET and makes several database [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vbworld.wordpress.com&amp;blog=3603633&amp;post=18&amp;subd=vbworld&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h3 class="docSection1Title">Recipe 13.6. Using  Transactions</h3>
<p><a title="idx-CHP-13-1190" name="idx-CHP-13-1190"></a><a title="vb2005ckbk-CHP-13-SECT-6.1" name="vb2005ckbk-CHP-13-SECT-6.1"></a></p>
<h4 class="docSection2Title">Problem</h4>
<p class="docText">You need to issue multiple database updates in the context of a  single, atomic transaction.</p>
<p><a title="vb2005ckbk-CHP-13-SECT-6.2" name="vb2005ckbk-CHP-13-SECT-6.2"></a></p>
<h4 class="docSection2Title">Solution</h4>
<p class="docText">Use an ADO.NET transaction to envelop the various SQL  statements that need to be processed as a unit.</p>
<p><a title="vb2005ckbk-CHP-13-SECT-6.3" name="vb2005ckbk-CHP-13-SECT-6.3"></a></p>
<h4 class="docSection2Title">Discussion</h4>
<p class="docText">The following block of code connects to a database via ADO.NET  and makes several database updates within a single transaction:</p>
<pre>	' ----- Connect to the database.
	Dim connectionString As String = _
	   "Data Source=MySystemSQLEXPRESS;" &amp; _
	   "Initial Catalog=MyDatabase;Integrated Security=true"
	Dim theDatabase As New SqlClient.SqlConnection(connectionString)
	theDatabase.Open( )	' ----- Create a command object that will hold each
	'       processed SQL statement.
	Dim sqlStatement As New SqlClient.SqlCommand
	sqlStatement.Connection = theDatabase	' ----- Start the transaction.
	Dim theTransaction As
        <a href="http://duniavb.blogspot.com/2010/09/database-using-transaction.html" target="_self">Read More &gt;&gt;</a></pre>
<h6 class="zemanta-related-title" style="font-size:1em;">Related Articles</h6>
<ul class="zemanta-article-ul">
<li class="zemanta-article-ul-li"><a href="http://msdn.microsoft.com/en-us/magazine/cc188705.aspx">The Enterprise Library Data Access Application Block, Part 2</a> (msdn.microsoft.com)</li>
</ul>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/vbworld.wordpress.com/18/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/vbworld.wordpress.com/18/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vbworld.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vbworld.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vbworld.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vbworld.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vbworld.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vbworld.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vbworld.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vbworld.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vbworld.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vbworld.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vbworld.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vbworld.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vbworld.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vbworld.wordpress.com/18/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vbworld.wordpress.com&amp;blog=3603633&amp;post=18&amp;subd=vbworld&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://vbworld.wordpress.com/2008/07/09/visual-studio-2005-cookbook-database-using-transactions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/ba8318d092db6de964aa444094c5fd10?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Admin</media:title>
		</media:content>
	</item>
		<item>
		<title>Visual Studio 2005 Cookbook &#8211; Database, Using Stored Procedures</title>
		<link>http://vbworld.wordpress.com/2008/07/09/visual-studio-2005-cookbook-database-using-stored-procedures/</link>
		<comments>http://vbworld.wordpress.com/2008/07/09/visual-studio-2005-cookbook-database-using-stored-procedures/#comments</comments>
		<pubDate>Wed, 09 Jul 2008 10:02:23 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[database]]></category>
		<category><![CDATA[programing]]></category>
		<category><![CDATA[vb.net]]></category>
		<category><![CDATA[FAQs Help and Tutorials]]></category>
		<category><![CDATA[Languages]]></category>
		<category><![CDATA[Microsoft SQL Server]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[Stored procedure]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[vb]]></category>
		<category><![CDATA[vb 2005]]></category>
		<category><![CDATA[visual basic.net]]></category>

		<guid isPermaLink="false">http://vbworld.wordpress.com/?p=17</guid>
		<description><![CDATA[Recipe 13.5. Using Stored Procedures Problem You need to use a stored procedure in your database, and you’re not sure how to specify values for its input and output parameters. Solution Use the command object’s Parameters collection to set and retrieve stored procedure argument values. Discussion Here’s a simple SQL Server stored procedure that does [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vbworld.wordpress.com&amp;blog=3603633&amp;post=17&amp;subd=vbworld&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h3 class="docSection1Title">Recipe 13.5. Using Stored  Procedures</h3>
<p><a name="idx-CHP-13-1188"></a><a name="vb2005ckbk-CHP-13-SECT-5.1"></a></p>
<h4 class="docSection2Title">Problem</h4>
<p class="docText">You need to use a stored procedure in your database, and you’re not sure how to specify values for its input and output parameters.</p>
<p><a name="vb2005ckbk-CHP-13-SECT-5.2"></a></p>
<h4 class="docSection2Title">Solution</h4>
<p class="docText">Use the command object’s <tt>Parameters</tt> collection to set  and retrieve stored procedure argument values.</p>
<p><a name="vb2005ckbk-CHP-13-SECT-5.3"></a></p>
<h4 class="docSection2Title">Discussion</h4>
<p class="docText">Here’s a simple SQL Server stored procedure that does nothing  more than retrieve a field from a table given its ID value:</p>
<pre>	CREATE PROCEDURE GetRecordName
	   @PriKey int,
	   @NameResult varchar(50) OUT
	AS
	BEGIN
	   -- Given an ID value, return the RecordName field.
	   SET @NameResult =
	      (SELECT RecordName FROM Table1 WHERE ID = @PriKey);
	END</pre>
<p class="docText">To use this stored procedure, create a command object that  calls it, and add separate input and output parameters: <a href="http://duniavb.blogspot.com/2010/09/database-using-stored-procedures.html" target="_blank">Read more&#8230;</a></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/vbworld.wordpress.com/17/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/vbworld.wordpress.com/17/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vbworld.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vbworld.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vbworld.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vbworld.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vbworld.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vbworld.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vbworld.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vbworld.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vbworld.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vbworld.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vbworld.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vbworld.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vbworld.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vbworld.wordpress.com/17/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vbworld.wordpress.com&amp;blog=3603633&amp;post=17&amp;subd=vbworld&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://vbworld.wordpress.com/2008/07/09/visual-studio-2005-cookbook-database-using-stored-procedures/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/ba8318d092db6de964aa444094c5fd10?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Admin</media:title>
		</media:content>
	</item>
		<item>
		<title>Ebook List</title>
		<link>http://vbworld.wordpress.com/2008/07/09/ebook-list/</link>
		<comments>http://vbworld.wordpress.com/2008/07/09/ebook-list/#comments</comments>
		<pubDate>Wed, 09 Jul 2008 04:54:33 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[ebook]]></category>
		<category><![CDATA[programing]]></category>
		<category><![CDATA[vb.net]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[vb 2005]]></category>
		<category><![CDATA[visual basic 2005]]></category>

		<guid isPermaLink="false">http://vbworld.wordpress.com/2008/05/27/ebook-list/</guid>
		<description><![CDATA[Ebook page contain : Visual Basic 2005 Cookbook Visual Basic 2005, a developers notebook.chm OReilly.Visual.Basic.2005.in.a.Nutshell.3rd.Edition.Jan.2006.chm Visual Basic 2005 Express Edition For Dummies Dec 2005 eBook-DDU.pdf You can download from here Blogged with the Flock Browser Tags: ebook, vb 2005, visual basic 2005<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vbworld.wordpress.com&amp;blog=3603633&amp;post=14&amp;subd=vbworld&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div class="snap_preview">
<p>Ebook page contain  :</p>
<ul>
<li>Visual Basic 2005 Cookbook</li>
<li>Visual Basic 2005, a developers notebook.chm</li>
<li>OReilly.Visual.Basic.2005.in.a.Nutshell.3rd.Edition.Jan.2006.chm</li>
<li>Visual Basic 2005 Express Edition For Dummies Dec 2005 eBook-DDU.pdf</li>
</ul>
<p>You can download from <a title="Ebbok" href="http://indragds.890m.com/vbworld/?page_id=5" target="_blank">here</a></div>
<div class="flockcredit" style="text-align:right;color:#CCC;font-size:x-small;">Blogged with the <a title="Flock Browser" href="http://www.flock.com/blogged-with-flock" target="_new">Flock Browser</a></div>
<p><!-- technorati tags begin --></p>
<p style="font-size:10px;text-align:right;">Tags: <a rel="tag" href="http://technorati.com/tag/ebook">ebook</a>, <a rel="tag" href="http://technorati.com/tag/vb%202005">vb 2005</a>, <a rel="tag" href="http://technorati.com/tag/%20visual%20basic%202005"> visual basic 2005</a></p>
<p><!-- technorati tags end --></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/vbworld.wordpress.com/14/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/vbworld.wordpress.com/14/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vbworld.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vbworld.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vbworld.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vbworld.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vbworld.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vbworld.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vbworld.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vbworld.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vbworld.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vbworld.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vbworld.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vbworld.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vbworld.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vbworld.wordpress.com/14/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vbworld.wordpress.com&amp;blog=3603633&amp;post=14&amp;subd=vbworld&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://vbworld.wordpress.com/2008/07/09/ebook-list/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/ba8318d092db6de964aa444094c5fd10?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Admin</media:title>
		</media:content>
	</item>
		<item>
		<title>Visual Studio 2005 Cookbook &#8211; Database, Using SQL Parameters</title>
		<link>http://vbworld.wordpress.com/2008/05/05/visual-studio-2005-cookbook-database-using-sql-parameters/</link>
		<comments>http://vbworld.wordpress.com/2008/05/05/visual-studio-2005-cookbook-database-using-sql-parameters/#comments</comments>
		<pubDate>Mon, 05 May 2008 10:44:34 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[database]]></category>
		<category><![CDATA[ebook]]></category>
		<category><![CDATA[programing]]></category>
		<category><![CDATA[vb.net]]></category>
		<category><![CDATA[parameter]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[vb]]></category>
		<category><![CDATA[visual basic 2005]]></category>

		<guid isPermaLink="false">http://vbworld.wordpress.com/?p=13</guid>
		<description><![CDATA[Recipe 13.4. Using SQL Parameters Problem You need to insert a lot of records into a table, and you would like to simply replace the new data values in the SQL statement without having to build the SQL statement from scratch each time. Solution Attach one or more Parameter objects to the Command object. Discussion [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vbworld.wordpress.com&amp;blog=3603633&amp;post=13&amp;subd=vbworld&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h3 class="docSection1Title">Recipe 13.4. Using SQL  Parameters</h3>
<p><a name="idx-CHP-13-1186"></a><a name="vb2005ckbk-CHP-13-SECT-4.1"></a></p>
<h4 class="docSection2Title">Problem</h4>
<p class="docText">You need to insert a lot of records into a table, and you would  like to simply replace the new data values in the SQL statement without having  to build the SQL statement from scratch each time.</p>
<p><a name="vb2005ckbk-CHP-13-SECT-4.2"></a></p>
<h4 class="docSection2Title">Solution</h4>
<p class="docText">Attach one or more <tt>Parameter</tt> objects to the  <tt>Command</tt> object.</p>
<p><a name="vb2005ckbk-CHP-13-SECT-4.3"></a></p>
<h4 class="docSection2Title">Discussion</h4>
<p class="docText">The following SQL Server example inserts new records<span id="more-13"></span> into  <tt>Table1</tt>, setting the <tt>Column2</tt> column to a distinct value for  each inserted record:</p>
<pre>	' ----- Connect to the database.
	Dim connectionString As String = _
	   "Data Source=MySystem\SQLEXPRESS;" &amp; _
	   "Initial Catalog=MyDatabase;Integrated Security=true"
	Dim theDatabase As New SqlClient.SqlConnection(connectionString)
	theDatabase.Open()

	' ----- Build the generic command text.
	Dim theCommand As New SqlClient.SqlCommand()
	theCommand.CommandText = _
	   "INSERT INTO Table1 (Column1) VALUES (@NewValue)"
	theCommand.Connection = theDatabase

	' ----- Add the first record.
	theCommand.Parameters.AddWithValue("NewValue", "Blue")
	theCommand.ExecuteNonQuery()

	' ----- Add the second record.
	theCommand.Parameters("NewValue").Value = "Red"
	theCommand.ExecuteNonQuery()

	' ----- Finished.
	theCommand = Nothing
	theDatabase.Close()
	theDatabase.Dispose()
</pre>
<p class="docText">Parameters are often used to interact with stored procedures,  but you can use them in other, more basic SQL statements to substitute for  placeholders included in the SQL statement text. In SQL Server, placeholders  begin with an at sign (<tt>@</tt>) followed by a parameter identifier. These  identifiers match the names used when creating <tt>SqlParameter</tt> objects.  These parameters are attached to the <tt>SqlCommand</tt> object containing the  generic SQL text.</p>
<p class="docText">Once you&#8217;ve created the command object, adding parameters is  simple. The easiest method employs the <tt>Parameters</tt> collection&#8217;s  <tt>AddWithValue()</tt> method to add the named parameters. This method accepts  a parameter name and a value as any <tt>System.Object</tt> instance:</p>
<pre>	theCommand.Parameters.AddWithValue("NewValue", "Blue")
</pre>
<p class="docText">Once the parameter is in place, you can modify it in later  statement reprocessing, accessing it by name:</p>
<pre>	theCommand.Parameters("NewValue").Value = "Red"
</pre>
<p class="docText">The exact syntax used to identify parameter placeholders in the  SQL statement text may vary between providers.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/vbworld.wordpress.com/13/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/vbworld.wordpress.com/13/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vbworld.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vbworld.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vbworld.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vbworld.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vbworld.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vbworld.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vbworld.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vbworld.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vbworld.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vbworld.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vbworld.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vbworld.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vbworld.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vbworld.wordpress.com/13/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vbworld.wordpress.com&amp;blog=3603633&amp;post=13&amp;subd=vbworld&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://vbworld.wordpress.com/2008/05/05/visual-studio-2005-cookbook-database-using-sql-parameters/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/ba8318d092db6de964aa444094c5fd10?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Admin</media:title>
		</media:content>
	</item>
		<item>
		<title>Visual Studio 2005 Cookbook &#8211; Database, Retrieving Results from a Database Query</title>
		<link>http://vbworld.wordpress.com/2008/05/05/visual-studio-2005-cookbook-database-retrieving-results-from-a-database-query/</link>
		<comments>http://vbworld.wordpress.com/2008/05/05/visual-studio-2005-cookbook-database-retrieving-results-from-a-database-query/#comments</comments>
		<pubDate>Mon, 05 May 2008 10:41:05 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[database]]></category>
		<category><![CDATA[ebook]]></category>
		<category><![CDATA[programing]]></category>
		<category><![CDATA[vb.net]]></category>
		<category><![CDATA[query]]></category>
		<category><![CDATA[vb]]></category>
		<category><![CDATA[visual basic]]></category>
		<category><![CDATA[visual basic 2005]]></category>

		<guid isPermaLink="false">http://vbworld.wordpress.com/?p=12</guid>
		<description><![CDATA[Recipe 13.3. Retrieving Results from a Database Query Problem You&#8217;ve issued INSERT, UPDATE, and DELETE statements through a command object, but you need to retrieve some data with a SELECT statement. Solution Use a DataReader object to quickly review the results of a SELECT statement. Discussion The following code retrieves a set of records from [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vbworld.wordpress.com&amp;blog=3603633&amp;post=12&amp;subd=vbworld&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h3 class="docSection1Title">Recipe 13.3. Retrieving Results from  a Database Query</h3>
<p><a name="vb2005ckbk-CHP-13-SECT-3.1"></a></p>
<h4 class="docSection2Title">Problem</h4>
<p class="docText">You&#8217;ve issued <tt>INSERT, UPDATE</tt>, and <tt>DELETE</tt> statements through a command object, but you need to retrieve some data with a  <tt>SELECT</tt> statement.</p>
<p><a name="vb2005ckbk-CHP-13-SECT-3.2"></a></p>
<h4 class="docSection2Title">Solution</h4>
<p class="docText">Use a <tt>DataReader</tt> object to quickly review the results  of a <tt>SELECT</tt> statement.</p>
<p><a name="vb2005ckbk-CHP-13-SECT-3.3"></a></p>
<h4 class="docSection2Title">Discussion</h4>
<p class="docText">The following code retrieves a<span id="more-12"></span> set of records from  <tt>Table1</tt>:</p>
<pre>	' ----- Connect to the database.
	Dim connectionString As String = _
	   "Data Source=MySystem\SQLEXPRESS;" &amp; _
	   "Initial Catalog=MyDatabase;Integrated Security=true"
	Dim theDatabase As New SqlClient.SqlConnection(connectionString)
	theDatabase.Open()

	' ----- Prepare the SQL statement for the reader.
	Dim sqlStatement As New SqlClient.SqlCommand( _
	   "SELECT * FROM Table1 WHERE Column2 = 25", _
	   theDatabase)
	Dim dataResults As SqlClient.SqlDataReader = _
	   sqlStatement.ExecuteReader()

	' ----- Clean up.
	sqlStatement = Nothing
	theDatabase.Close()
	theDatabase.Dispose()
</pre>
<p class="docText">Assuming that the query returned records, the  <tt>dataResults</tt> object now makes those records available, one at a time.  The <tt><a name="idx-CHP-13-1183"></a>Read()</tt> method retrieves each successive  record from the database:</p>
<pre>	Do While dataResults.Read()
	   MsgBox("Column1 = " &amp; CStr(dataResults!Column1))
	Loop
	dataResults.Close()
</pre>
<p class="docText"><tt>Read()</tt> returns <tt>False</tt> when there are no more  records available.</p>
<p class="docText">To check for the presence of any records before using the  <tt>Read()</tt> method, use the <tt>HasRows</tt> property:</p>
<pre>	If (dataResults.HasRows = False) Then MsgBox("No data.")
</pre>
<p class="docText">Data readers provide basic and direct access to result sets.  They are no-frills objects, but they are quick and simple to use. Their basic  and essential features form the basis of other, more complex data-gathering  actions in ADO.NET. When you retrieve table results and store them in a  <tt>DataSet</tt> object (described in <a class="docLink" href="vb2005ckbk-CHP-13-SECT-7.html#vb2005ckbk-CHP-13-SECT-7">Recipe 13.7</a>),  the <tt>DataSet</tt> indirectly uses a data reader to transfer the records from  the database into the data set.</p>
<p class="docText">Records returned by a data reader can be accessed by name or  position. For example, if you retrieve data with the columns <tt>Column1,  Column2</tt>, and <tt>Column3</tt> (in that order), you can use any of the  following statements to access <tt>Column2</tt>:</p>
<pre>	dataResults!Column2
	dataResults("Column2")
	dataResults(1)  ' Zero-based array.
</pre>
<p class="docText">The fields returned by the reader are stored as  <tt>System.Object</tt> values. You must convert them to their proper data types  manually, using the available conversion functions.</p>
<p class="docText">Data readers are &#8220;forward-only&#8221; objects; once you have  retrieved a record using <tt>Read()</tt>, you cannot return to it without  reissuing the SQL command to create a new data reader.</p>
<p class="docText">While data readers are most often used to process  <tt>SELECT</tt> statements and stored procedures, there are other statements  that return data results. SQL Server 2005 includes a new <tt>OUTPUT</tt> clause  in <tt>INSERT</tt> statements that you can use to retrieve one or more data  fields from the newly inserted record. It&#8217;s common to create a database table  with an automatically generated numeric primary key. After inserting a new  record into such a table, you have to use a separate <tt>SELECT</tt> statement  to retrieve the new primary key value. The <tt>OUTPUT</tt> clause lets you  retrieve the new primary key value directly from the <tt>INSERT</tt> statement:</p>
<pre>	INSERT INTO Table1 (Column2, Column3)
	   OUTPUT INSERTED.Column1
	   VALUES (10, 20)
</pre>
<p class="docText">Sending this <tt>INSERT</tt> statement to the database using  the <tt><a name="idx-CHP-13-1184"></a>ExecuteReader()</tt> method returns a single  record with a single field containing the value of the new <tt>Column1</tt> field. You can also use the <tt><a name="idx-CHP-13-1185"></a>ExecuteScalar()</tt> method because only a single value is returned:</p>
<pre>	Dim sqlStatement As New SqlClient.SqlCommand( _
	   "INSERT INTO Table1 (Column2, Column3) " &amp; _
	   "OUTPUT INSERTED.Column1 VALUES (10, 20)", _
	   theDatabase)
	Dim newID As Integer = CInt(sqlStatement.ExecuteScalar())
	sqlStatement = Nothing
</pre>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/vbworld.wordpress.com/12/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/vbworld.wordpress.com/12/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vbworld.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vbworld.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vbworld.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vbworld.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vbworld.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vbworld.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vbworld.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vbworld.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vbworld.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vbworld.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vbworld.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vbworld.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vbworld.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vbworld.wordpress.com/12/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vbworld.wordpress.com&amp;blog=3603633&amp;post=12&amp;subd=vbworld&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://vbworld.wordpress.com/2008/05/05/visual-studio-2005-cookbook-database-retrieving-results-from-a-database-query/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/ba8318d092db6de964aa444094c5fd10?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Admin</media:title>
		</media:content>
	</item>
		<item>
		<title>Visual Basic 2005 Cookbook &#8211; Database, Issuing SQL Commands</title>
		<link>http://vbworld.wordpress.com/2008/04/29/visual-basic-2005-cookbook-database-issuing-sql-commands/</link>
		<comments>http://vbworld.wordpress.com/2008/04/29/visual-basic-2005-cookbook-database-issuing-sql-commands/#comments</comments>
		<pubDate>Tue, 29 Apr 2008 11:27:02 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[database]]></category>
		<category><![CDATA[ebook]]></category>
		<category><![CDATA[programing]]></category>
		<category><![CDATA[vb.net]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[vb]]></category>

		<guid isPermaLink="false">http://vbworld.wordpress.com/?p=11</guid>
		<description><![CDATA[Recipe 13.2. Issuing SQL Commands Problem Now that you&#8217;ve established a connection to a database through a provider, you&#8217;re ready to issue SQL commands. But how? Solution Use a Command object to issue SQL commands directly to your database through the provider connection. Discussion The following code updates a SQL Server table named Table1, changing [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vbworld.wordpress.com&amp;blog=3603633&amp;post=11&amp;subd=vbworld&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h3 class="docSection1Title">Recipe 13.2. Issuing SQL  Commands</h3>
<p><a name="idx-CHP-13-1175"></a><a name="vb2005ckbk-CHP-13-SECT-2.1"></a></p>
<h4 class="docSection2Title">Problem</h4>
<p class="docText">Now that you&#8217;ve established a connection to a database through  a provider, you&#8217;re ready to issue SQL <a name="idx-CHP-13-1176"></a>commands. But  how?</p>
<p><a name="vb2005ckbk-CHP-13-SECT-2.2"></a></p>
<h4 class="docSection2Title">Solution</h4>
<p class="docText">Use a <tt>Command</tt> object to issue <a name="idx-CHP-13-1177"></a>SQL commands directly to your database through the  provider connection.</p>
<p><a name="vb2005ckbk-CHP-13-SECT-2.3"></a></p>
<h4 class="docSection2Title">Discussion</h4>
<p class="docText">The following code updates a SQL Server table named  <tt>Table1</tt>, changing every <tt>Column2</tt> field to <tt>25</tt> whenever  <tt>Column1</tt> has a value of <tt>0</tt>:</p>
<pre>	' ----- Connect to the database.
	Dim connectionString As String = _
	   "Data Source=MySystem\SQLEXPRESS;" &amp; _
	   "Initial Catalog=MyDatabase;Integrated Security=true"
	Dim theDatabase As New SqlClient.SqlConnection(connectionString)
	theDatabase.Open()

	' ----- Prepare the SQL statement for use.
	Dim sqlStatement As New SqlClient.SqlCommand( _
	   "UPDATE Table1 SET Column2 = 25 WHERE Column1 = 0", _
	   theDatabase)
	sqlStatement.ExecuteNonQuery()

	' ----- Clean up.
	theDatabase.Close()
	theDatabase.Dispose()
</pre>
<p class="docText">Just like connections, command objects are provider-specific.  When using the SQL Server<span id="more-11"></span> provider, the <tt>System.Data.SqlClient.<a name="idx-CHP-13-1178"></a> SqlCommand</tt> class wraps a SQL statement string and  prepares it for use by the database. You must supply a valid SQL statement that  is recognizable by the database.</p>
<p class="docText">The SQL statement you provide to the command can include the  standard <a name="idx-CHP-13-1179"></a>Data Manipulation Language (DML) SQL  statements <tt>(SELECT, INSERT, UPDATE, DELETE)</tt>, or any of the  platform-specific <a name="idx-CHP-13-1180"></a>Data Definition Language (DDL)  statements (such as <tt>CREATE TABLE</tt>). Do not include a terminating  semicolon in the statement.</p>
<p class="docText">Instead of including the SQL statement and connection object in  the command&#8217;s constructor, you can assign these values to the command object&#8217;s  <tt>CommandText</tt> and <tt>Connection</tt> properties, respectively.</p>
<p class="docText">The command object includes several <a name="idx-CHP-13-1181"></a>methods that send the command to the database for  processing:</p>
<p><a name="idx-CHP-13-1182"></a></p>
<dl>
<dt> <span class="docPubcolor"><span class="docPubcolor"><span class="docMonofont">ExecuteReader()</span></span></span></p>
</dt>
<dd>
<p class="docList">Issues a command, and returns the data results in the form of a  <tt><a name="idx-CHP-13-1182"></a>DataReader</tt> object. See <a class="docLink" href="vb2005ckbk-CHP-13-SECT-3.html#vb2005ckbk-CHP-13-SECT-3">Recipe 13.3</a> for additional information on data readers.</p>
</dd>
<dt> <span class="docPubcolor"><span class="docPubcolor"><span class="docMonofont">ExecuteNonQuery()</span></span></span></p>
</dt>
<dd>
<p class="docList">Issues a command, expecting no results. This method is  generally used for <tt>INSERT, UPDATE</tt>, and <tt>DELETE</tt> commands.</p>
</dd>
<dt> <span class="docPubcolor"><span class="docPubcolor"><span class="docMonofont">ExecuteScalar()</span></span></span></p>
</dt>
<dd>
<p class="docList">Issues a command, expecting a single row and column of data in  response. The data is returned as a generic <tt>System.Object</tt> instance,  which you can convert to the appropriate data type.</p>
</dd>
<dt> <span class="docPubcolor"><span class="docPubcolor"><span class="docMonofont">ExecuteXmlReader()</span></span></span></p>
</dt>
<dd>
<p class="docList">Issues a command, and returns the data results as an  <tt>XmlReader</tt> object.</p>
</dd>
</dl>
<p class="docText">There are also asynchronous versions of these methods (except  for <tt>ExecuteScalar()</tt>).</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/vbworld.wordpress.com/11/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/vbworld.wordpress.com/11/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vbworld.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vbworld.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vbworld.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vbworld.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vbworld.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vbworld.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vbworld.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vbworld.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vbworld.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vbworld.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vbworld.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vbworld.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vbworld.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vbworld.wordpress.com/11/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vbworld.wordpress.com&amp;blog=3603633&amp;post=11&amp;subd=vbworld&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://vbworld.wordpress.com/2008/04/29/visual-basic-2005-cookbook-database-issuing-sql-commands/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/ba8318d092db6de964aa444094c5fd10?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Admin</media:title>
		</media:content>
	</item>
	</channel>
</rss>
