<?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:series="http://unfoldingneurons.com/"
> <channel><title>Linglom.com &#187; Programming</title> <atom:link href="http://www.linglom.com/category/programming/feed/" rel="self" type="application/rss+xml" /><link>http://www.linglom.com</link> <description>Source of IT knowledge</description> <lastBuildDate>Wed, 07 Dec 2011 14:03:35 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>Enable cURL on XAMPP</title><link>http://www.linglom.com/2011/09/01/enable-curl-on-xampp/</link> <comments>http://www.linglom.com/2011/09/01/enable-curl-on-xampp/#comments</comments> <pubDate>Thu, 01 Sep 2011 08:53:15 +0000</pubDate> <dc:creator>linglom</dc:creator> <category><![CDATA[Programming]]></category> <category><![CDATA[Windows]]></category> <category><![CDATA[cURL]]></category> <category><![CDATA[XAMPP]]></category> <guid
isPermaLink="false">http://www.linglom.com/?p=1352</guid> <description><![CDATA[cURL is client-side URL transfer library which allows you to connect and communicate to many different types of servers with many different types of protocols. It supports http, https, ftp, gopher, telnet, dict, file, and ldap protocols. This article shows you how to enable cURL on XAMPP on Windows 7. Step-by-step Locate php.ini in xampp [...]
No related posts.]]></description> <content:encoded><![CDATA[<p>cURL is client-side URL transfer library which allows you to connect and communicate to many different types of servers with many different types of protocols. It supports http, https, ftp, gopher, telnet, dict, file, and ldap protocols.</p><p><span
id="more-1352"></span></p><p>This article shows you how to enable cURL on XAMPP on Windows 7.</p><p> <?php @include_once("/home/nipawit/public_html/linglom/adlogger/ad_check_include.php"); if ($show_ads == 'y') { ?> <script type="text/javascript">google_ad_client = "ca-pub-7765165459812980";
/* 336 x 280. created 12/7/10 */
google_ad_slot = "2657223297";
google_ad_width = 336;
google_ad_height = 280;</script> <script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script> <?php } ?></p><h3>Step-by-step</h3><ol><li>Locate php.ini in xampp directory. By default, it locates in <strong>&#8220;xampp/php/php.ini&#8221;</strong>. Then, open the file with any text editor.<br
/> <a
href="http://www.linglom.com/images/Windows/Enable-cURL-on-XAMPP/1.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Enable-cURL-on-XAMPP/_1.png" width="200" height="150" alt="Locate PHP.INI" title="Locate PHP.INI"  /></a></li><li>Uncomment the line below by remove the semi-colon at beginning of the line and save the file.<div
class="wp_syntax"><div
class="code"><pre class="text" style="font-family:monospace;">;extension=php_curl.dll</pre></div></div><p>to</p><div
class="wp_syntax"><div
class="code"><pre class="text" style="font-family:monospace;">extension=php_curl.dll</pre></div></div><p><a
href="http://www.linglom.com/images/Windows/Enable-cURL-on-XAMPP/2.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Enable-cURL-on-XAMPP/_2.png" width="200" height="182" alt="Uncomment php_curl.dll" title="Uncomment php_curl.dll"  /></a></li><li>Next, restart apache service. You can do this through Windows services or using XAMPP Control Panel. Open <strong>XAMPP Control Panel</strong>, click on <strong>Stop</strong> button of the Apache service. Once it stops, click <strong>Start</strong> button.<br
/> <a
href="http://www.linglom.com/images/Windows/Enable-cURL-on-XAMPP/3.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Enable-cURL-on-XAMPP/_3.png" width="200" height="160" alt="Restart Apache service" title="Restart Apache service"  /></a></li><li>Now cURL is enabled on XAMPP, you can test by create a PHP file with the code below and save to htdocs folder.<pre class="brush: php; title: ; notranslate">
 &lt;?php
  phpinfo();
?&gt;
</pre><p><a
href="http://www.linglom.com/images/Windows/Enable-cURL-on-XAMPP/4.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Enable-cURL-on-XAMPP/_4.png" width="200" height="150" alt="phpinfo()" title="phpinfo()"  /></a></li><li>Open the browser and navigate to http://localhost/phpinfo.php. Scroll down to find curl section, you will see that it is already enabled. If you can&#8217;t find curl section, it means that cURL isn&#8217;t enable on the server.<br
/> <a
href="http://www.linglom.com/images/Windows/Enable-cURL-on-XAMPP/5.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Enable-cURL-on-XAMPP/_5.png" width="200" height="144" alt="cURL is enabled" title="cURL is enabled"  /></a></li></ol><p>No related posts.</p>]]></content:encoded> <wfw:commentRss>http://www.linglom.com/2011/09/01/enable-curl-on-xampp/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Creating Graph with VB.NET, Part 3: Data Binding Chart to Database</title><link>http://www.linglom.com/2010/05/27/creating-graph-with-vb-net-part-3-data-binding-chart-to-database/</link> <comments>http://www.linglom.com/2010/05/27/creating-graph-with-vb-net-part-3-data-binding-chart-to-database/#comments</comments> <pubDate>Thu, 27 May 2010 09:40:36 +0000</pubDate> <dc:creator>linglom</dc:creator> <category><![CDATA[Programming]]></category> <category><![CDATA[VB.NET]]></category> <category><![CDATA[Chart]]></category> <category><![CDATA[Dot Net]]></category> <guid
isPermaLink="false">http://www.linglom.com/?p=1153</guid> <description><![CDATA[From Part 1: Basic Chart and Part 2: Customize Chart, you see how to create a basic chart using GUI (no coding). But the chart is static, it&#8217;s lack flexibility which means that you cannot change properties or data of the chart while the application is running. Therefore, I will show how to create a [...]
Related posts:<ol><li><a
href='http://www.linglom.com/2010/05/11/creating-graph-with-vb-net-part-1-basic-chart/' rel='bookmark' title='Creating Graph with VB.NET, Part 1: Basic Chart'>Creating Graph with VB.NET, Part 1: Basic Chart</a> <small>This series shows how to create chart or graph with...</small></li><li><a
href='http://www.linglom.com/2010/05/14/creating-graph-with-vb-net-part-2-customize-chart/' rel='bookmark' title='Creating Graph with VB.NET, Part 2: Customize Chart'>Creating Graph with VB.NET, Part 2: Customize Chart</a> <small>On Part 1: Basic Chart, I show how to create...</small></li></ol>]]></description> <content:encoded><![CDATA[<p>From Part 1: Basic Chart and Part 2: Customize Chart, you see how to create a basic chart using GUI (no coding). But the chart is static, it&#8217;s lack flexibility which means that you cannot change properties or data of the chart while the application is running. Therefore, I will show how to create a chart by coding and bind data from a SQL Server&#8217;s database to the Chart control.</p><p><span
id="more-1153"></span></p><p></p><p>On this example, I will create a connection to &#8220;<strong>Northwind</strong>&#8221; database on this SQL Server &#8220;<strong>BKKSQL001\INSTANCE01</strong>&#8221; and query product name and units in stock from &#8220;<strong>Products</strong>&#8221; table. Then, I create a chart and bind the query&#8217;s result to the chart.</p><h3>Step-by-step</h3><ol><li>Create a new Windows Application project on VB.NET and type name as &#8220;<strong>SampleDataBindChart</strong>&#8220;.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-3/1.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-3/_1.png" width="200" height="122" alt="Create New VB.NET's Windows Application" title="Create New VB.NET's Windows Application"  /></a></li><li>On <strong>Form1</strong>, open code window and import these libraries. The first two libraries are used for SQL. The last one is used for Chart.<div
class="wp_syntax"><div
class="code"><pre class="vbnet" style="font-family:monospace;"><span style="color: #0600FF;">Imports</span> System.<span style="color: #0000FF;">Data</span>
<span style="color: #0600FF;">Imports</span> System.<span style="color: #0000FF;">Data</span>.<span style="color: #0000FF;">SqlClient</span>
&nbsp;
<span style="color: #0600FF;">Imports</span> System.<span style="color: #0000FF;">Windows</span>.<span style="color: #0000FF;">Forms</span>.<span style="color: #0000FF;">DataVisualization</span>.<span style="color: #0000FF;">Charting</span></pre></div></div><p><a
href="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-3/2.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-3/_2.png" width="200" height="122" alt="Import Required Libraries" title="Import Required Libraries"  /></a></li><li>Type code below on Form1_Load().<div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
</pre></td><td
class="code"><pre class="vbnet" style="font-family:monospace;">        <span style="color: #0600FF;">Dim</span> strConn <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Data Source=BKKSQL001\INSTANCE01;&quot;</span> <span style="color: #008000;">&amp;</span> _
            <span style="color: #808080;">&quot;Initial Catalog=Northwind;Integrated Security=True&quot;</span>
&nbsp;
        <span style="color: #0600FF;">Dim</span> conn <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">New</span> SqlConnection<span style="color: #000000;">&#40;</span>strConn<span style="color: #000000;">&#41;</span>
&nbsp;
        <span style="color: #0600FF;">Dim</span> sqlProducts <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;SELECT Top 8 ProductName, UnitsInStock FROM Products&quot;</span>
        <span style="color: #0600FF;">Dim</span> da <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">New</span> SqlDataAdapter<span style="color: #000000;">&#40;</span>sqlProducts, conn<span style="color: #000000;">&#41;</span>
        <span style="color: #0600FF;">Dim</span> ds <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">New</span> DataSet<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        da.<span style="color: #0000FF;">Fill</span><span style="color: #000000;">&#40;</span>ds, <span style="color: #808080;">&quot;Products&quot;</span><span style="color: #000000;">&#41;</span>
&nbsp;
        <span style="color: #0600FF;">Dim</span> ChartArea1 <span style="color: #FF8000;">As</span> ChartArea <span style="color: #008000;">=</span> <span style="color: #FF8000;">New</span> ChartArea<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #0600FF;">Dim</span> Legend1 <span style="color: #FF8000;">As</span> Legend <span style="color: #008000;">=</span> <span style="color: #FF8000;">New</span> Legend<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #0600FF;">Dim</span> Series1 <span style="color: #FF8000;">As</span> Series <span style="color: #008000;">=</span> <span style="color: #FF8000;">New</span> Series<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #0600FF;">Dim</span> Chart1 <span style="color: #008000;">=</span> <span style="color: #FF8000;">New</span> Chart<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #FF8000;">Me</span>.<span style="color: #0000FF;">Controls</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span>Chart1<span style="color: #000000;">&#41;</span>
&nbsp;
        ChartArea1.<span style="color: #0000FF;">Name</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;ChartArea1&quot;</span>
        Chart1.<span style="color: #0000FF;">ChartAreas</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span>ChartArea1<span style="color: #000000;">&#41;</span>
        Legend1.<span style="color: #0000FF;">Name</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Legend1&quot;</span>
        Chart1.<span style="color: #0000FF;">Legends</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span>Legend1<span style="color: #000000;">&#41;</span>
        Chart1.<span style="color: #0000FF;">Location</span> <span style="color: #008000;">=</span> <span style="color: #FF8000;">New</span> System.<span style="color: #0000FF;">Drawing</span>.<span style="color: #0000FF;">Point</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">13</span>, <span style="color: #FF0000;">13</span><span style="color: #000000;">&#41;</span>
        Chart1.<span style="color: #0000FF;">Name</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Chart1&quot;</span>
        Series1.<span style="color: #0000FF;">ChartArea</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;ChartArea1&quot;</span>
        Series1.<span style="color: #0000FF;">Legend</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Legend1&quot;</span>
        Series1.<span style="color: #0000FF;">Name</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Series1&quot;</span>
        Chart1.<span style="color: #0000FF;">Series</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span>Series1<span style="color: #000000;">&#41;</span>
        Chart1.<span style="color: #0000FF;">Size</span> <span style="color: #008000;">=</span> <span style="color: #FF8000;">New</span> System.<span style="color: #0000FF;">Drawing</span>.<span style="color: #0000FF;">Size</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">800</span>, <span style="color: #FF0000;">400</span><span style="color: #000000;">&#41;</span>
        Chart1.<span style="color: #0000FF;">TabIndex</span> <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span>
        Chart1.<span style="color: #0000FF;">Text</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Chart1&quot;</span>
&nbsp;
        Chart1.<span style="color: #0000FF;">Series</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Series1&quot;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">XValueMember</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;ProductName&quot;</span>
        Chart1.<span style="color: #0000FF;">Series</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Series1&quot;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">YValueMembers</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;UnitsInStock&quot;</span>
&nbsp;
        Chart1.<span style="color: #0000FF;">DataSource</span> <span style="color: #008000;">=</span> ds.<span style="color: #0000FF;">Tables</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Products&quot;</span><span style="color: #000000;">&#41;</span></pre></td></tr></table></div><p><strong>Code Explanation</strong>:</p><ul><li>Line 1-2: Define a connection string to connect to a database on SQL Server.<ul><li><strong>Data Source</strong> is a SQL Server name.</li><li><strong>Initial Catalog</strong> is a database name.</li><li>Set <strong>Integrated Security=True</strong> to use the current user as identity to access the SQL Server database.</li></ul></li><li>Line 4: Create a SqlConnection&#8217;s object.</li><li>Line 6: Define SQL query string.</li><li>Line 7-9: Execute the query and populate result to DataSet&#8217;s object.</li><li>Line 11-14: Create Chart&#8217;s objects.</li><li>Line 15: Add Chart&#8217;s object to the form.</li><li>Line 17-29: Set Chart&#8217;s properties (ChartArea, Legend and Series).</li><li>Line 31-32: Bind column &#8220;<strong>ProductName</strong>&#8221; to X-axis and column &#8220;<strong>UnitsInStock</strong>&#8221; to Y-axis on the &#8220;<strong>Series1</strong>&#8221; Chart.</li><li>Line 34: Set Chart&#8217;s data source to the DataTable in the DataSet&#8217;s object.</li></ul><p><a
href="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-3/3.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-3/_3.png" width="200" height="150" alt="Form1_Load's code" title="Form1_Load's code"  /></a></li><li>Run the project. You see a chart displaying &#8220;<strong>Product Name</strong>&#8221; on X-axis and &#8220;<strong>Unit in Stock</strong>&#8221; on Y-axis which data is gathered from Northwind database on SQL Server.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-3/4.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-3/_4.png" width="200" height="121" alt="A chart binding to Database on SQL Server" title="A chart binding to Database on SQL Server"  /></a></li></ol><p>Related posts:<ol><li><a
href='http://www.linglom.com/2010/05/11/creating-graph-with-vb-net-part-1-basic-chart/' rel='bookmark' title='Creating Graph with VB.NET, Part 1: Basic Chart'>Creating Graph with VB.NET, Part 1: Basic Chart</a> <small>This series shows how to create chart or graph with...</small></li><li><a
href='http://www.linglom.com/2010/05/14/creating-graph-with-vb-net-part-2-customize-chart/' rel='bookmark' title='Creating Graph with VB.NET, Part 2: Customize Chart'>Creating Graph with VB.NET, Part 2: Customize Chart</a> <small>On Part 1: Basic Chart, I show how to create...</small></li></ol></p>]]></content:encoded> <wfw:commentRss>http://www.linglom.com/2010/05/27/creating-graph-with-vb-net-part-3-data-binding-chart-to-database/feed/</wfw:commentRss> <slash:comments>29</slash:comments> <series:name><![CDATA[Creating Graph with VB.NET]]></series:name> </item> <item><title>Creating Graph with VB.NET, Part 2: Customize Chart</title><link>http://www.linglom.com/2010/05/14/creating-graph-with-vb-net-part-2-customize-chart/</link> <comments>http://www.linglom.com/2010/05/14/creating-graph-with-vb-net-part-2-customize-chart/#comments</comments> <pubDate>Fri, 14 May 2010 07:45:20 +0000</pubDate> <dc:creator>linglom</dc:creator> <category><![CDATA[Programming]]></category> <category><![CDATA[VB.NET]]></category> <category><![CDATA[Chart]]></category> <category><![CDATA[Dot Net]]></category> <guid
isPermaLink="false">http://www.linglom.com/?p=1151</guid> <description><![CDATA[On Part 1: Basic Chart, I show how to create a basic chart with default chart type and color style. Now you will see how to customize those properties on a chart. Sections Sample chart Change chart type Change color style Insert title to chart 3D chart Sample chart The sample chart that I use [...]
Related posts:<ol><li><a
href='http://www.linglom.com/2010/05/11/creating-graph-with-vb-net-part-1-basic-chart/' rel='bookmark' title='Creating Graph with VB.NET, Part 1: Basic Chart'>Creating Graph with VB.NET, Part 1: Basic Chart</a> <small>This series shows how to create chart or graph with...</small></li><li><a
href='http://www.linglom.com/2010/05/27/creating-graph-with-vb-net-part-3-data-binding-chart-to-database/' rel='bookmark' title='Creating Graph with VB.NET, Part 3: Data Binding Chart to Database'>Creating Graph with VB.NET, Part 3: Data Binding Chart to Database</a> <small>From Part 1: Basic Chart and Part 2: Customize Chart,...</small></li></ol>]]></description> <content:encoded><![CDATA[<p>On Part 1: Basic Chart, I show how to create a basic chart with default chart type and color style. Now you will see how to customize those properties on a chart.</p><p><span
id="more-1151"></span></p><p></p><p><a
name="top"></a></p><h3>Sections</h3><ul><li><a
href="#1">Sample chart</a></li><li><a
href="#2">Change chart type</a></li><li><a
href="#3">Change color style</a></li><li><a
href="#4">Insert title to chart</a></li><li><a
href="#5">3D chart</a></li></ul><p><a
name="1"></a></p><h3>Sample chart</h3><p>The sample chart that I use on this post has a series &#8220;<strong>Series1</strong>&#8221; which has 3 data points &#8220;<strong>10,20,30</strong>&#8220;.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-2/1.png" target="_blank"><img
title="Sample chart" src="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-2/_1.png" alt="Sample chart" width="200" height="215" /></a></p><p><a
href="#top">Back to top</a></p><p><a
name="2"></a></p><h3>Change chart type</h3><p>There are many chart types that you can select for Chart control. On this example, I show some of those chart types which are Point, Line, Bar, Pie.</p><ol><li>On <strong>Chart Properties</strong>, click the <strong>Series</strong> collection. Then, click the ellipsis button.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-2/2.png" target="_blank"><img
title="Chart Properties" src="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-2/_2.png" alt="Chart Properties" width="200" height="282" /></a></li><li>On <strong>Series Collection Editor</strong>, select &#8220;<strong>Series1</strong>&#8221; in the Members area and change the <strong>Chart type</strong> property to <strong>Point</strong>.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-2/3.png" target="_blank"><img
title="Change Chart Type" src="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-2/_3.png" alt="Change Chart Type" width="200" height="147" /></a></li><li>The <strong>Point</strong> chart type.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-2/4.png" target="_blank"><img
title="Point Chart" src="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-2/_4.png" alt="Point Chart" width="200" height="215" /></a></li><li>The <strong>Line</strong> chart type.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-2/5.png" target="_blank"><img
class=" alignnone" title="Line Chart" src="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-2/_5.png" alt="Line Chart" width="200" height="215" /></a></li><li>The <strong>Bar</strong> chart type.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-2/6.png" target="_blank"><img
title="Bar Chart" src="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-2/_6.png" alt="Bar Chart" width="200" height="215" /></a></li><li>The <strong>Pie</strong> chart type.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-2/7.png" target="_blank"><img
title="Pie Chart" src="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-2/_7.png" alt="Pie Chart" width="200" height="215" /></a></li></ol><p><a
href="#top">Back to top</a></p><p><a
name="3"></a></p><h3>Change Color style of chart</h3><p>There are many color palettes that you can choose for Chart control. This section shows how to change color of Chart control.</p><ol><li>On <strong>Chart Properties</strong>, click on <strong>Palette</strong> property. You see a drop down button. Click on it and you can choose a color palette for your chart.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-2/8.png" target="_blank"><img
title="Change Color Palette" src="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-2/_8.png" alt="Change Color Palette" width="200" height="249" /></a></li><li>The example below is <strong>Bright</strong> color palette.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-2/9.png" target="_blank"><img
title="Sample Chart" src="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-2/_9.png" alt="Sample Chart" width="200" height="215" /></a></li></ol><p><a
href="#top">Back to top</a></p><p><a
name="4"></a></p><h3>Insert title to chart</h3><p>This section shows how to insert title to Chart control.</p><ol><li>On <strong>Chart Properties</strong>, click the <strong>Title</strong> collection. Then, click the ellipsis button.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-2/10.png" target="_blank"><img
title="Chart Properties" src="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-2/_10.png" alt="Chart Properties" width="200" height="249" /></a></li><li>On <strong>Title Collection Editor</strong>, click <strong>Add</strong> and set <strong>(Text)</strong> to &#8220;<strong>My Sample Chart</strong>&#8221; in the newly created Title object.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-2/11.png" target="_blank"><img
title="Add Title" src="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-2/_11.png" alt="Add Title" width="200" height="147" /></a></li><li>Run the project. You will see a title on top of the chart.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-2/12.png" target="_blank"><img
title="Sample Chart with title" src="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-2/_12.png" alt="Sample Chart with title" width="200" height="215" /></a></li><li>You can customize title&#8217;s text style, title position, title color on title properties.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-2/13.png" target="_blank"><img
title="Title Properties" src="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-2/_13.png" alt="Title Properties" width="200" height="147" /></a></li></ol><p><a
href="#top">Back to top</a></p><p><a
name="5"></a></p><h3>3D chart</h3><p>This section shows how to use three-dimensional (3D) chart areas in Chart control.</p><ol><li>On <strong>Chart Properties</strong>, click the <strong>ChartAreas</strong> collection. Then, click the ellipsis button.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-2/14.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-2/_14.png" width="200" height="249" alt="Open ChartArea Collection Editor" title="Open ChartArea Collection Editor"  /></a></li><li>On <strong>ChartArea Collection Editor</strong>, select &#8220;<strong>ChartArea1</strong>&#8220;. Expand <strong>Area3DStyle</strong> and change <strong>(Enable3D)</strong> to <strong>True</strong>.<br
/> <em><strong>Note:</strong></em> You can customize your 3D Style on this <strong>Area3DStyle</strong> properties .<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-2/15.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-2/_15.png" width="200" height="147" alt="Enable 3D Chart" title="Enable 3D Chart"  /></a></li><li>You see the chart is now 3D.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-2/16.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-2/_16.png" width="200" height="215" alt="Sample 3D Chart" title="Sample 3D Chart"  /></a></li></ol><p><a
href="#top">Back to top</a></p><p>Related posts:<ol><li><a
href='http://www.linglom.com/2010/05/11/creating-graph-with-vb-net-part-1-basic-chart/' rel='bookmark' title='Creating Graph with VB.NET, Part 1: Basic Chart'>Creating Graph with VB.NET, Part 1: Basic Chart</a> <small>This series shows how to create chart or graph with...</small></li><li><a
href='http://www.linglom.com/2010/05/27/creating-graph-with-vb-net-part-3-data-binding-chart-to-database/' rel='bookmark' title='Creating Graph with VB.NET, Part 3: Data Binding Chart to Database'>Creating Graph with VB.NET, Part 3: Data Binding Chart to Database</a> <small>From Part 1: Basic Chart and Part 2: Customize Chart,...</small></li></ol></p>]]></content:encoded> <wfw:commentRss>http://www.linglom.com/2010/05/14/creating-graph-with-vb-net-part-2-customize-chart/feed/</wfw:commentRss> <slash:comments>5</slash:comments> <series:name><![CDATA[Creating Graph with VB.NET]]></series:name> </item> <item><title>Creating Graph with VB.NET, Part 1: Basic Chart</title><link>http://www.linglom.com/2010/05/11/creating-graph-with-vb-net-part-1-basic-chart/</link> <comments>http://www.linglom.com/2010/05/11/creating-graph-with-vb-net-part-1-basic-chart/#comments</comments> <pubDate>Tue, 11 May 2010 04:21:33 +0000</pubDate> <dc:creator>linglom</dc:creator> <category><![CDATA[Programming]]></category> <category><![CDATA[VB.NET]]></category> <category><![CDATA[Chart]]></category> <category><![CDATA[Dot Net]]></category> <guid
isPermaLink="false">http://www.linglom.com/?p=1148</guid> <description><![CDATA[This series shows how to create chart or graph with VB.NET using Microsoft Chart Controls for .NET Framework. I divide the series into 3 parts: Creating Graph with VB.NET, Part 1: Basic Chart Creating Graph with VB.NET, Part 2: Customize Chart Creating Graph with VB.NET, Part 3: Data Binding Chart to Database On this post, [...]
Related posts:<ol><li><a
href='http://www.linglom.com/2010/05/14/creating-graph-with-vb-net-part-2-customize-chart/' rel='bookmark' title='Creating Graph with VB.NET, Part 2: Customize Chart'>Creating Graph with VB.NET, Part 2: Customize Chart</a> <small>On Part 1: Basic Chart, I show how to create...</small></li><li><a
href='http://www.linglom.com/2010/05/27/creating-graph-with-vb-net-part-3-data-binding-chart-to-database/' rel='bookmark' title='Creating Graph with VB.NET, Part 3: Data Binding Chart to Database'>Creating Graph with VB.NET, Part 3: Data Binding Chart to Database</a> <small>From Part 1: Basic Chart and Part 2: Customize Chart,...</small></li></ol>]]></description> <content:encoded><![CDATA[<p>This series shows how to create chart or graph with VB.NET using Microsoft Chart Controls for .NET Framework.</p><p><span
id="more-1148"></span></p><p>I divide the series into 3 parts:</p><ol><li>Creating Graph with VB.NET, Part 1: Basic Chart</li><li>Creating Graph with VB.NET, Part 2: Customize Chart</li><li>Creating Graph with VB.NET, Part 3: Data Binding Chart to Database</li></ol><p></p><p>On this post, you will learn how to create a basic chart on Windows Form Application with VB.NET. I use Microsoft Visual Studio 2005 as IDE.</p><h3>Requirement</h3><ul><li>Microsoft Visual Studio 2005 or later.</li><li>.NET Framework 3.5 SP1 or later. You can download <a
href="http://www.microsoft.com/downloads/details.aspx?familyid=AB99342F-5D1A-413D-8319-81DA479AB0D7&#038;displaylang=en" target="_blank" rel="nofollow">Microsoft .NET Framework 3.5 Service Pack 1</a> from Microsoft website.</li><li><a
href="http://www.microsoft.com/downloads/details.aspx?FamilyId=130F7986-BF49-4FE5-9CA8-910AE6EA442C&#038;displaylang=en" target="_blank" rel="nofollow">Microsoft Chart Controls for Microsoft .NET Framework 3.5</a></li></ul><h3>Step-by-step</h3><ol><li>Install the requirement software as stated on the Requirement section.</li><li>Open Microsoft Visual Studio 2005. Create a new VB.NET&#8217;s Windows Application. Type the name of the project as &#8220;<strong>SampleBasicChart</strong>&#8220;.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-1/1.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-1/_1.png" width="200" height="122" alt="Create Windows Application's Project" title="Create Windows Application's Project"  /></a></li><li>On <strong>Toolbox</strong> window, drag a <strong>Chart</strong> control from the <strong>Data</strong> category to the Windows Form.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-1/2.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-1/_2.png" width="200" height="188" alt="A Chart Control" title="A Chart Control"  /></a><br
/> <strong><em>Note</em></strong>: If you does not see the Chart control in the Toolbox, you need to perform these steps below:</p><ul><li>Right-click on the <strong>Toolbox</strong> window and select <strong>Choose Items</strong>.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-1/3.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-1/_3.png" width="200" height="158" alt="Add New Item to Toolbox" title="Add New Item to Toolbox"  /></a></li><li>On <strong>Choose Toolbox Items</strong>, click Browse.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-1/4.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-1/_4.png" width="200" height="143" alt="Browse the Component" title="Browse the Component"  /></a></li><li>Browse to the location where you have installed Microsoft Chart Controls. The default location is<br
/> C:\Program Files\Microsoft Chart Controls\Assemblies and select <strong>System.Windows.Forms.DataVisualization.dll</strong>. Then, click <strong>Open</strong>.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-1/5.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-1/_5.png" width="200" height="131" alt="System.Windows.Forms.DataVisualization.dll" title="System.Windows.Forms.DataVisualization.dll"  /></a></li><li>You see Chart control has been added to .NET Framework Components. Verify that its check box is checked and click <strong>OK</strong>.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-1/6.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-1/_6.png" width="200" height="143" alt="Chat Control Component" title="Chat Control Component"  /></a></li></ul></li><li>On <strong>Chart Properties</strong>, you see an empty chart with a default series, &#8220;<strong>Series1</strong>&#8220;. Next, I&#8217;m going to add another Series. On <strong>Chart Properties</strong>, click the <strong>Series</strong> collection. Then, click the ellipsis button.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-1/7.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-1/_7.png" width="200" height="250" alt="Chart Properties" title="Chart Properties"  /></a></li><li>On <strong>Series Collection Editor</strong>, click <strong>Add</strong>. You will see &#8220;<strong>Series2</strong>&#8221; has been added to the collection.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-1/8.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-1/_8.png" width="200" height="147" alt="Series Collection Editor" title="Series Collection Editor"  /></a></li><li>Now you have two series on a chart. But there is not any data on the chart so I will add some example data point on each series. Select <strong>Series1</strong> and click the ellipsis button on <strong>Points</strong> collection.</li><li>On <strong>Series Collection Editor</strong>, select &#8220;<strong>Series1</strong>&#8221; in the <strong>Members</strong> area and click the <strong>Points</strong> collection property. Then, click the ellipsis button.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-1/9.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-1/_9.png" width="200" height="147" alt="Add Data Points" title="Add Data Points"  /></a></li><li>On <strong>DataPoint Collection Editor</strong>, click <strong>Add</strong> and assign a value &#8220;<strong>10</strong>&#8221; to the <strong>YValues</strong> property in the newly created DataPoint object.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-1/10.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-1/_10.png" width="200" height="147" alt="Set YValues on DataPoint" title="Set YValues on DataPoint"  /></a></li><li>Repeat step 8 to add two more DataPoint object with values &#8220;<strong>20</strong>&#8221; and &#8220;<strong>30</strong>&#8221; repectively. Then, click <strong>OK</strong> to close the <strong>DataPoint Collection Editor</strong> window.<br
/> <em><strong>Note</strong></em>:  These values are example values, you may use any value as you want.</li><li>Repeat step 7-9 again on &#8220;<strong>Series2</strong>&#8221; with <strong>YValues</strong> as you want. Then, click <strong>OK</strong> to close the <strong>Series Collection Editor</strong> windows.</li><li>Run the project. You see the chart with two series as you created.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-1/11.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/Dot-Net/Chart-Control/Part-1/_11.png" width="200" height="215" alt="A Basic Chart" title="A Basic Chart"  /></a></li></ol><p>Related posts:<ol><li><a
href='http://www.linglom.com/2010/05/14/creating-graph-with-vb-net-part-2-customize-chart/' rel='bookmark' title='Creating Graph with VB.NET, Part 2: Customize Chart'>Creating Graph with VB.NET, Part 2: Customize Chart</a> <small>On Part 1: Basic Chart, I show how to create...</small></li><li><a
href='http://www.linglom.com/2010/05/27/creating-graph-with-vb-net-part-3-data-binding-chart-to-database/' rel='bookmark' title='Creating Graph with VB.NET, Part 3: Data Binding Chart to Database'>Creating Graph with VB.NET, Part 3: Data Binding Chart to Database</a> <small>From Part 1: Basic Chart and Part 2: Customize Chart,...</small></li></ol></p>]]></content:encoded> <wfw:commentRss>http://www.linglom.com/2010/05/11/creating-graph-with-vb-net-part-1-basic-chart/feed/</wfw:commentRss> <slash:comments>4</slash:comments> <series:name><![CDATA[Creating Graph with VB.NET]]></series:name> </item> <item><title>Accessing SQL Server on ASP.NET Web Application using ADO.NET</title><link>http://www.linglom.com/2010/04/14/accessing-sql-server-on-asp-net-web-application-using-ado-net/</link> <comments>http://www.linglom.com/2010/04/14/accessing-sql-server-on-asp-net-web-application-using-ado-net/#comments</comments> <pubDate>Wed, 14 Apr 2010 06:28:21 +0000</pubDate> <dc:creator>linglom</dc:creator> <category><![CDATA[ASP.NET]]></category> <category><![CDATA[Programming]]></category> <category><![CDATA[Windows]]></category> <category><![CDATA[ADO.NET]]></category> <category><![CDATA[SQL Server]]></category> <guid
isPermaLink="false">http://www.linglom.com/?p=1089</guid> <description><![CDATA[ADO.NET is a set of components that can be used to access data and data services. The objects of ADO.NET that will be used in this post are: Connection: Provides a connection used to communicate with the data source. DataAdapter: A bridge used to transfer data between a Data source and a DataSet object. DataSet: [...]
Related posts:<ol><li><a
href='http://www.linglom.com/2010/03/26/accessing-sql-server-on-asp-net-web-application-using-sqldatasource-web-control-part-1-select-data/' rel='bookmark' title='Accessing SQL Server on ASP.NET Web Application using SqlDataSource Web Control, Part 1: SELECT Data'>Accessing SQL Server on ASP.NET Web Application using SqlDataSource Web Control, Part 1: SELECT Data</a> <small>Accessing SQL Server on ASP.NET Web Application using SqlDataSource Web...</small></li><li><a
href='http://www.linglom.com/2010/04/02/accessing-sql-server-on-asp-net-web-application-using-sqldatasource-web-control-part-2-update-data/' rel='bookmark' title='Accessing SQL Server on ASP.NET Web Application using SqlDataSource Web Control, Part 2: UPDATE Data'>Accessing SQL Server on ASP.NET Web Application using SqlDataSource Web Control, Part 2: UPDATE Data</a> <small>Accessing SQL Server on ASP.NET Web Application using SqlDataSource Web...</small></li><li><a
href='http://www.linglom.com/2008/08/26/create-dynamic-rss-feed-from-ms-sql-server-using-aspnet-part-i-vbnet/' rel='bookmark' title='Create Dynamic RSS Feed from MS SQL Server using ASP.NET, Part I: VB.NET'>Create Dynamic RSS Feed from MS SQL Server using ASP.NET, Part I: VB.NET</a> <small>Introduction Before I started, let&#8217;s get to know what RSS...</small></li></ol>]]></description> <content:encoded><![CDATA[<p>ADO.NET is a set of components that can be used to access data and data services. The objects of ADO.NET that will be used in this post are:<span
id="more-1089"></span></p><ul><li><strong>Connection</strong>: Provides a connection used to communicate with the data source.</li><li><strong>DataAdapter</strong>: A bridge used to transfer data between a Data source and a DataSet object.</li><li><strong>DataSet</strong>: Stores query result from DataAdapter.</li></ul><p></p><p>On this post, you will see how to develop an ASP.NET web application that query data from SQL Server 2005 and display the result on a GridView object. I have provided both VB.NET and C# programming languages.</p><h3>Step-by-step</h3><ol><li>Create a connection string in web.config. I decide to put the connection string in web.config so that I can re-use the connection string in other web form.<div
class="wp_syntax"><div
class="code"><pre class="asp" style="font-family:monospace;"><span style="color: #006600; font-weight: bold;">&lt;</span>connectionstrings<span style="color: #006600; font-weight: bold;">&gt;</span>
		<span style="color: #006600; font-weight: bold;">&lt;</span>add name<span style="color: #006600; font-weight: bold;">=</span><span style="color: #cc0000;">&quot;Northwind&quot;</span>
       connectionString<span style="color: #006600; font-weight: bold;">=</span><span style="color: #cc0000;">&quot;Data Source=BKKSQL001\INSTANCE01;
       Initial Catalog=Northwind;
       Integrated Security=True&quot;</span>
      providerName<span style="color: #006600; font-weight: bold;">=</span><span style="color: #cc0000;">&quot;System.Data.SqlClient&quot;</span><span style="color: #006600; font-weight: bold;">/&gt;</span>
<span style="color: #006600; font-weight: bold;">&lt;/</span>connectionstrings<span style="color: #006600; font-weight: bold;">&gt;</span></pre></div></div><p><strong>Attributes explanation:</strong></p><ul><li><strong>name</strong>: A connection string name.</li><li><strong>connectionString</strong>: A connection string which is used to connect to a database. On this example, it connects to Northwind database on BKKSQL001\INSTANCE01.</li><li><strong>providerName</strong>: A provider name that is used.</li></ul><p><a
href="http://www.linglom.com/images/Windows/Programming/ASP.NET/Access-SQLServer/ADO.NET/1.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/ASP.NET/Access-SQLServer/ADO.NET/_1.png" width="200" height="150" alt="A Connection String" title="A Connection String"  /></a></li><li>On a Web Form, imports some namespaces which are required for working with SQL Server. System.Web.Configuration is use to read values from web.config.<div
class="wp_syntax"><div
class="code"><pre class="vbnet" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">'Visual Basic</span>
<span style="color: #0600FF;">Imports</span> System.<span style="color: #0000FF;">Data</span>
<span style="color: #0600FF;">Imports</span> System.<span style="color: #0000FF;">Data</span>.<span style="color: #0000FF;">SqlClient</span>
<span style="color: #0600FF;">Imports</span> System.<span style="color: #0000FF;">Web</span>.<span style="color: #0000FF;">Configuration</span></pre></div></div><div
class="wp_syntax"><div
class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">//C#</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Data</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Data.SqlClient</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Web.Configuration</span><span style="color: #008000;">;</span></pre></div></div></li><li>Use a GridView object to display the query result. Set the name of GridView to &#8220;<strong>gridView1</strong>&#8220;. Copy and paste the code below to <strong>Page_Load</strong> method.<div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td
class="code"><pre class="vbnet" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">'Visual Basic</span>
Protected <span style="color: #0600FF;">Sub</span> Page_Load<span style="color: #000000;">&#40;</span><span style="color: #FF8000;">ByVal</span> sender <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Object</span>, <span style="color: #FF8000;">ByVal</span> e <span style="color: #FF8000;">As</span> System.<span style="color: #0000FF;">EventArgs</span><span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Handles</span> <span style="color: #FF8000;">Me</span>.<span style="color: #0000FF;">Load</span>
&nbsp;
        <span style="color: #0600FF;">Dim</span> connStr <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span> <span style="color: #008000;">=</span> WebConfigurationManager.<span style="color: #0000FF;">ConnectionStrings</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Northwind&quot;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">ConnectionString</span>
        <span style="color: #0600FF;">Dim</span> conn <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">New</span> SqlConnection<span style="color: #000000;">&#40;</span>connStr<span style="color: #000000;">&#41;</span>
        conn.<span style="color: #0600FF;">Open</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
&nbsp;
        <span style="color: #0600FF;">Dim</span> sqlProducts <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;SELECT ProductID, ProductName, UnitPrice FROM Products&quot;</span>
&nbsp;
        <span style="color: #0600FF;">Dim</span> da <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">New</span> SqlDataAdapter<span style="color: #000000;">&#40;</span>sqlProducts, conn<span style="color: #000000;">&#41;</span>
        <span style="color: #0600FF;">Dim</span> ds <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">New</span> DataSet<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        da.<span style="color: #0000FF;">Fill</span><span style="color: #000000;">&#40;</span>ds, <span style="color: #808080;">&quot;Products&quot;</span><span style="color: #000000;">&#41;</span>
&nbsp;
        gridView1.<span style="color: #0000FF;">DataSource</span> <span style="color: #008000;">=</span> ds.<span style="color: #0000FF;">Tables</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;Products&quot;</span><span style="color: #000000;">&#41;</span>
        gridView1.<span style="color: #0000FF;">Databind</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span></pre></td></tr></table></div><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td
class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">//C#</span>
<span style="color: #0600FF; font-weight: bold;">protected</span> <span style="color: #6666cc; font-weight: bold;">void</span> Page_Load<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> sender, EventArgs e<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #6666cc; font-weight: bold;">string</span> connStr <span style="color: #008000;">=</span> WebConfigurationManager<span style="color: #008000;">.</span><span style="color: #0000FF;">ConnectionStrings</span><span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;Northwind&quot;</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ConnectionString</span><span style="color: #008000;">;</span>
        SqlConnection conn <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> SqlConnection<span style="color: #008000;">&#40;</span>connStr<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        conn<span style="color: #008000;">.</span><span style="color: #0000FF;">Open</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #6666cc; font-weight: bold;">string</span> sqlProducts <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;SELECT ProductID, ProductName, UnitPrice FROM Products&quot;</span><span style="color: #008000;">;</span>
&nbsp;
        SqlDataAdapter da <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> SqlDataAdapter<span style="color: #008000;">&#40;</span>sqlProducts, conn<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        DataSet ds <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> DataSet<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        da<span style="color: #008000;">.</span><span style="color: #0000FF;">Fill</span><span style="color: #008000;">&#40;</span>ds, <span style="color: #666666;">&quot;Products&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        gridView1<span style="color: #008000;">.</span><span style="color: #0000FF;">DataSource</span> <span style="color: #008000;">=</span> ds<span style="color: #008000;">.</span><span style="color: #0000FF;">Tables</span><span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;Products&quot;</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span>
        gridView1<span style="color: #008000;">.</span><span style="color: #0000FF;">DataBind</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span></pre></td></tr></table></div><p><strong>Code Explanation:</strong></p><ul><li>Line 4-6: Get a connection string value from web.config. Then, open a connection using the connection string to a SQL Server.</li><li>Line 8: Create a variable &#8220;<strong>sqlProducts</strong>&#8221; which stores SQL query from Products table.</li><li>Line 10-12: Create a SqlDataAdapter object &#8220;<strong>da</strong>&#8221; to execute the query. Then, create a DataSet object &#8220;<strong>ds</strong>&#8221; to hold the result from object &#8220;<strong>da</strong>&#8221; and set name to &#8220;<strong>Products</strong>&#8220;.</li><li>Line 14-15: Display data from object &#8220;<strong>ds</strong>&#8221; on a GridView object &#8220;<strong>gridView1</strong>&#8220;.</li></ul></li><li>Run the project. You will see the result as figure below.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/ASP.NET/Access-SQLServer/ADO.NET/2.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/ASP.NET/Access-SQLServer/ADO.NET/_2.png" width="200" height="247" alt="Northwind's Products table" title="Northwind's Products table"  /></a></li></ol><p>Related posts:<ol><li><a
href='http://www.linglom.com/2010/03/26/accessing-sql-server-on-asp-net-web-application-using-sqldatasource-web-control-part-1-select-data/' rel='bookmark' title='Accessing SQL Server on ASP.NET Web Application using SqlDataSource Web Control, Part 1: SELECT Data'>Accessing SQL Server on ASP.NET Web Application using SqlDataSource Web Control, Part 1: SELECT Data</a> <small>Accessing SQL Server on ASP.NET Web Application using SqlDataSource Web...</small></li><li><a
href='http://www.linglom.com/2010/04/02/accessing-sql-server-on-asp-net-web-application-using-sqldatasource-web-control-part-2-update-data/' rel='bookmark' title='Accessing SQL Server on ASP.NET Web Application using SqlDataSource Web Control, Part 2: UPDATE Data'>Accessing SQL Server on ASP.NET Web Application using SqlDataSource Web Control, Part 2: UPDATE Data</a> <small>Accessing SQL Server on ASP.NET Web Application using SqlDataSource Web...</small></li><li><a
href='http://www.linglom.com/2008/08/26/create-dynamic-rss-feed-from-ms-sql-server-using-aspnet-part-i-vbnet/' rel='bookmark' title='Create Dynamic RSS Feed from MS SQL Server using ASP.NET, Part I: VB.NET'>Create Dynamic RSS Feed from MS SQL Server using ASP.NET, Part I: VB.NET</a> <small>Introduction Before I started, let&#8217;s get to know what RSS...</small></li></ol></p>]]></content:encoded> <wfw:commentRss>http://www.linglom.com/2010/04/14/accessing-sql-server-on-asp-net-web-application-using-ado-net/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item><title>Accessing SQL Server on ASP.NET Web Application using SqlDataSource Web Control, Part 2: UPDATE Data</title><link>http://www.linglom.com/2010/04/02/accessing-sql-server-on-asp-net-web-application-using-sqldatasource-web-control-part-2-update-data/</link> <comments>http://www.linglom.com/2010/04/02/accessing-sql-server-on-asp-net-web-application-using-sqldatasource-web-control-part-2-update-data/#comments</comments> <pubDate>Fri, 02 Apr 2010 03:32:54 +0000</pubDate> <dc:creator>linglom</dc:creator> <category><![CDATA[ASP.NET]]></category> <category><![CDATA[Programming]]></category> <category><![CDATA[Windows]]></category> <category><![CDATA[SQL Server]]></category> <category><![CDATA[SqlDataSource]]></category> <guid
isPermaLink="false">http://www.linglom.com/?p=1095</guid> <description><![CDATA[Accessing SQL Server on ASP.NET Web Application using SqlDataSource Web Control, Part 2: UPDATE Data From part 1: SELECT Data, you see how to query data from SQL Server 2005 to display on a GridView object using SqlDataSource web control. But the data is read-only, you cannot modify any data on a GridView. So now [...]
Related posts:<ol><li><a
href='http://www.linglom.com/2010/03/26/accessing-sql-server-on-asp-net-web-application-using-sqldatasource-web-control-part-1-select-data/' rel='bookmark' title='Accessing SQL Server on ASP.NET Web Application using SqlDataSource Web Control, Part 1: SELECT Data'>Accessing SQL Server on ASP.NET Web Application using SqlDataSource Web Control, Part 1: SELECT Data</a> <small>Accessing SQL Server on ASP.NET Web Application using SqlDataSource Web...</small></li><li><a
href='http://www.linglom.com/2010/04/14/accessing-sql-server-on-asp-net-web-application-using-ado-net/' rel='bookmark' title='Accessing SQL Server on ASP.NET Web Application using ADO.NET'>Accessing SQL Server on ASP.NET Web Application using ADO.NET</a> <small>ADO.NET is a set of components that can be used...</small></li><li><a
href='http://www.linglom.com/2008/08/26/create-dynamic-rss-feed-from-ms-sql-server-using-aspnet-part-i-vbnet/' rel='bookmark' title='Create Dynamic RSS Feed from MS SQL Server using ASP.NET, Part I: VB.NET'>Create Dynamic RSS Feed from MS SQL Server using ASP.NET, Part I: VB.NET</a> <small>Introduction Before I started, let&#8217;s get to know what RSS...</small></li></ol>]]></description> <content:encoded><![CDATA[<h3>Accessing SQL Server on ASP.NET Web Application using SqlDataSource Web Control, Part 2: UPDATE Data</h3><p><span
id="more-1095"></span></p><p>From <a
href="http://www.linglom.com/2010/03/26/accessing-sql-server-on-asp-net-web-application-using-sqldatasource-web-control-part-1-select-data/">part 1: SELECT Data</a>, you see how to query data from SQL Server 2005 to display on a GridView object using <strong>SqlDataSource</strong> web control. But the data is read-only, you cannot modify any data on a GridView. So now you will see how to modify data on the GridView which will update back on the database.</p><p></p><h3>Step-by-step</h3><p><em><strong>Note:</strong></em> This example is continue from part 1: SELECT Data.</p><ol><li>On SqlDataSource1, click on <strong>Configure Data Source</strong>.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/ASP.NET/Access-SQLServer/SqlDataSource/Part-2/1.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/ASP.NET/Access-SQLServer/SqlDataSource/Part-2/_1.png" width="200" height="129" alt="Configure Data Source" title="Configure Data Source"  /></a></li><li>On <strong>Choose Your Data Connection</strong>, click <strong>Next</strong>.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/ASP.NET/Access-SQLServer/SqlDataSource/Part-2/2.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/ASP.NET/Access-SQLServer/SqlDataSource/Part-2/_2.png" width="200" height="155" alt="Choose Your Data Connection" title="Choose Your Data Connection"  /></a></li><li>On <strong>Configure Select Statement</strong>, change the option from <strong>Specify columns from a table or view</strong> to <strong>Specify a custom SQL statement or stored procedure</strong>. Click <strong>Next</strong>.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/ASP.NET/Access-SQLServer/SqlDataSource/Part-2/3.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/ASP.NET/Access-SQLServer/SqlDataSource/Part-2/_3.png" width="200" height="155" alt="Configure Select Statement" title="Configure Select Statement"  /></a></li><li>On <strong>Define Custom Statements or Stored Procedures</strong>, you see 4 tabs which are SELECT, UPDATE, INSERT and DELETE. Here you can define custom SQL statements for each SQL operations. On <strong>SELECT</strong> tab, enter the SQL statement as below:<div
class="wp_syntax"><div
class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">&#91;</span>ProductID<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">,</span> <span style="color: #66cc66;">&#91;</span>ProductName<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">,</span> <span style="color: #66cc66;">&#91;</span>UnitPrice<span style="color: #66cc66;">&#93;</span> <span style="color: #993333; font-weight: bold;">FROM</span> <span style="color: #66cc66;">&#91;</span>Products<span style="color: #66cc66;">&#93;</span></pre></div></div><p><a
href="http://www.linglom.com/images/Windows/Programming/ASP.NET/Access-SQLServer/SqlDataSource/Part-2/4.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/ASP.NET/Access-SQLServer/SqlDataSource/Part-2/_4.png" width="200" height="155" alt="Define Custom Statements or Stored Procedures" title="Define Custom Statements or Stored Procedures"  /></a></li><li>Click on <strong>UPDATE</strong> tab, enter the SQL statement below and click <strong>Next</strong>.<div
class="wp_syntax"><div
class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">UPDATE</span> Products <span style="color: #993333; font-weight: bold;">SET</span> ProductName <span style="color: #66cc66;">=</span> @ProductName<span style="color: #66cc66;">,</span> UnitPrice <span style="color: #66cc66;">=</span> @UnitPrice
<span style="color: #993333; font-weight: bold;">WHERE</span> <span style="color: #66cc66;">&#91;</span>ProductID<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">=</span> @ProductID</pre></div></div><p><a
href="http://www.linglom.com/images/Windows/Programming/ASP.NET/Access-SQLServer/SqlDataSource/Part-2/5.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/ASP.NET/Access-SQLServer/SqlDataSource/Part-2/_5.png" width="200" height="155" alt="Update SQL Query" title="Update SQL Query"  /></a></li><li>On <strong>Test Query</strong>, Click <strong>Finish</strong>.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/ASP.NET/Access-SQLServer/SqlDataSource/Part-2/6.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/ASP.NET/Access-SQLServer/SqlDataSource/Part-2/_6.png" width="200" height="155" alt="Test Query" title="Test Query"  /></a></li><li>On <strong>GridView1</strong>, click <strong>Edit Columns</strong>.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/ASP.NET/Access-SQLServer/SqlDataSource/Part-2/7.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/ASP.NET/Access-SQLServer/SqlDataSource/Part-2/_7.png" width="200" height="129" alt="Edit Columns" title="Edit Columns"  /></a></li><li>On <strong>Fields</strong>, select <strong>Command Fields</strong> -> <strong>Edit, Update, Cancel</strong> on <strong>Available fields</strong> and click <strong>Add</strong>. Then, move the field <strong>Edit, Update, Cancel</strong> to the top by click on up arrow button. Next, click <strong>OK</strong>.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/ASP.NET/Access-SQLServer/SqlDataSource/Part-2/8.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/ASP.NET/Access-SQLServer/SqlDataSource/Part-2/_8.png" width="200" height="163" alt="Add Fields on Grid View Web Control" title="Add Fields on Grid View Web Control"  /></a></li><li>On <strong>GridView1</strong>, check <strong>Enable Editing</strong> to allow edit data on the Grid View.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/ASP.NET/Access-SQLServer/SqlDataSource/Part-2/9.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/ASP.NET/Access-SQLServer/SqlDataSource/Part-2/_9.png" width="200" height="129" alt="Enable Editing" title="Enable Editing"  /></a></li><li>Build and run the project. You see the <strong>Edit</strong> column in front of each row. Click <strong>Edit</strong> to edit the row.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/ASP.NET/Access-SQLServer/SqlDataSource/Part-2/10.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/ASP.NET/Access-SQLServer/SqlDataSource/Part-2/_10.png" width="200" height="273" alt="Query Result" title="Query Result"  /></a></li><li>You can modify the value of product name and unit price of the row which also update back on the database, too.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/ASP.NET/Access-SQLServer/SqlDataSource/Part-2/11.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/ASP.NET/Access-SQLServer/SqlDataSource/Part-2/_11.png" width="200" height="195" alt="Edit a Row" title="Edit a Row"  /></a></li></ol><p>Related posts:<ol><li><a
href='http://www.linglom.com/2010/03/26/accessing-sql-server-on-asp-net-web-application-using-sqldatasource-web-control-part-1-select-data/' rel='bookmark' title='Accessing SQL Server on ASP.NET Web Application using SqlDataSource Web Control, Part 1: SELECT Data'>Accessing SQL Server on ASP.NET Web Application using SqlDataSource Web Control, Part 1: SELECT Data</a> <small>Accessing SQL Server on ASP.NET Web Application using SqlDataSource Web...</small></li><li><a
href='http://www.linglom.com/2010/04/14/accessing-sql-server-on-asp-net-web-application-using-ado-net/' rel='bookmark' title='Accessing SQL Server on ASP.NET Web Application using ADO.NET'>Accessing SQL Server on ASP.NET Web Application using ADO.NET</a> <small>ADO.NET is a set of components that can be used...</small></li><li><a
href='http://www.linglom.com/2008/08/26/create-dynamic-rss-feed-from-ms-sql-server-using-aspnet-part-i-vbnet/' rel='bookmark' title='Create Dynamic RSS Feed from MS SQL Server using ASP.NET, Part I: VB.NET'>Create Dynamic RSS Feed from MS SQL Server using ASP.NET, Part I: VB.NET</a> <small>Introduction Before I started, let&#8217;s get to know what RSS...</small></li></ol></p>]]></content:encoded> <wfw:commentRss>http://www.linglom.com/2010/04/02/accessing-sql-server-on-asp-net-web-application-using-sqldatasource-web-control-part-2-update-data/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>Accessing SQL Server on ASP.NET Web Application using SqlDataSource Web Control, Part 1: SELECT Data</title><link>http://www.linglom.com/2010/03/26/accessing-sql-server-on-asp-net-web-application-using-sqldatasource-web-control-part-1-select-data/</link> <comments>http://www.linglom.com/2010/03/26/accessing-sql-server-on-asp-net-web-application-using-sqldatasource-web-control-part-1-select-data/#comments</comments> <pubDate>Fri, 26 Mar 2010 04:40:26 +0000</pubDate> <dc:creator>linglom</dc:creator> <category><![CDATA[ASP.NET]]></category> <category><![CDATA[Programming]]></category> <category><![CDATA[Windows]]></category> <category><![CDATA[SqlDataSource]]></category> <guid
isPermaLink="false">http://www.linglom.com/?p=1092</guid> <description><![CDATA[Accessing SQL Server on ASP.NET Web Application using SqlDataSource Web Control, Part 1: SELECT Data On this post, you will see how to develop an ASP.NET web application that query data from SQL Server 2005 and display the result on a GridView object using SqlDataSource web control so you don&#8217;t have to write any code! [...]
Related posts:<ol><li><a
href='http://www.linglom.com/2010/04/02/accessing-sql-server-on-asp-net-web-application-using-sqldatasource-web-control-part-2-update-data/' rel='bookmark' title='Accessing SQL Server on ASP.NET Web Application using SqlDataSource Web Control, Part 2: UPDATE Data'>Accessing SQL Server on ASP.NET Web Application using SqlDataSource Web Control, Part 2: UPDATE Data</a> <small>Accessing SQL Server on ASP.NET Web Application using SqlDataSource Web...</small></li><li><a
href='http://www.linglom.com/2010/04/14/accessing-sql-server-on-asp-net-web-application-using-ado-net/' rel='bookmark' title='Accessing SQL Server on ASP.NET Web Application using ADO.NET'>Accessing SQL Server on ASP.NET Web Application using ADO.NET</a> <small>ADO.NET is a set of components that can be used...</small></li><li><a
href='http://www.linglom.com/2008/08/26/create-dynamic-rss-feed-from-ms-sql-server-using-aspnet-part-i-vbnet/' rel='bookmark' title='Create Dynamic RSS Feed from MS SQL Server using ASP.NET, Part I: VB.NET'>Create Dynamic RSS Feed from MS SQL Server using ASP.NET, Part I: VB.NET</a> <small>Introduction Before I started, let&#8217;s get to know what RSS...</small></li></ol>]]></description> <content:encoded><![CDATA[<h3>Accessing SQL Server on ASP.NET Web Application using SqlDataSource Web Control, Part 1: SELECT Data</h3><p><span
id="more-1092"></span></p><p>On this post, you will see how to develop an ASP.NET web application that query data from SQL Server 2005 and display the result on a GridView object using <strong>SqlDataSource</strong> web control so you don&#8217;t have to write any code!</p><p></p><h3>Step-by-step-</h3><ol><li>Drag a <strong>SqlDataSource</strong> object from Toolbox to a Web Form.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/ASP.NET/Access-SQLServer/SqlDataSource/Part-1/1.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/ASP.NET/Access-SQLServer/SqlDataSource/Part-1/_1.png" width="200" height="233" alt="SqlDataSource" title="SqlDataSource"  /></a></li><li>On <strong>SqlDataSource1</strong> object, click <strong>Configure Data Source</strong>.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/ASP.NET/Access-SQLServer/SqlDataSource/Part-1/2.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/ASP.NET/Access-SQLServer/SqlDataSource/Part-1/_2.png" width="200" height="129" alt="Configure Data Source" title="Configure Data Source"  /></a></li><li>On <strong>Choose Your Data Connection</strong>, click <strong>New Connection</strong>.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/ASP.NET/Access-SQLServer/SqlDataSource/Part-1/3.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/ASP.NET/Access-SQLServer/SqlDataSource/Part-1/_3.png" width="200" height="155" alt="Create a New Connection" title="Create a New Connection"  /></a></li><li>On <strong>Add Connection</strong>, select <strong>Data Source</strong> as <strong>Microsoft SQL Server (SqlClient)</strong>. Then, type the Server name of the SQL Server and select a database. On this example, the server is <strong>BKKSQL001\INSTANCE01</strong> and <strong>Northwind</strong> is the database.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/ASP.NET/Access-SQLServer/SqlDataSource/Part-1/4.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/ASP.NET/Access-SQLServer/SqlDataSource/Part-1/_4.png" width="200" height="301" alt="Add Connection" title="Add Connection"  /></a></li><li>On <strong>Save the Connection String to the Application Configuration File</strong>, click <strong>Next</strong> to continue.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/ASP.NET/Access-SQLServer/SqlDataSource/Part-1/5.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/ASP.NET/Access-SQLServer/SqlDataSource/Part-1/_5.png" width="200" height="155" alt="Save the Connection String" title="Save the Connection String"  /></a></li><li>On <strong>Configure the Select Statement</strong>, select <strong>Specify columns from table or view</strong> and select <strong>Products</strong> table. Then, check <strong>ProductID</strong>, <strong>ProductName</strong> and <strong>UnitPrice</strong> columns. Click <strong>Next</strong>.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/ASP.NET/Access-SQLServer/SqlDataSource/Part-1/6.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/ASP.NET/Access-SQLServer/SqlDataSource/Part-1/_6.png" width="200" height="155" alt="Configure the Select Statement" title="Configure the Select Statement"  /></a></li><li>On <strong>Test Query</strong>, you can click on <strong>Test Query</strong> button to verify the query result. Then, click <strong>Finish</strong>.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/ASP.NET/Access-SQLServer/SqlDataSource/Part-1/7.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/ASP.NET/Access-SQLServer/SqlDataSource/Part-1/_7.png" width="200" height="155" alt="Test Query" title="Test Query"  /></a></li><li>Drag a GridView object from Toolbox to the Web Form. Then, choose the Data Source to the one that you have just created.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/ASP.NET/Access-SQLServer/SqlDataSource/Part-1/8.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/ASP.NET/Access-SQLServer/SqlDataSource/Part-1/_8.png" width="200" height="129" alt="Set Data Source for GridView Object" title="Set Data Source for GridView Object"  /></a></li><li>Build and run the project. You will see the result as the figure below.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/ASP.NET/Access-SQLServer/SqlDataSource/Part-1/9.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/ASP.NET/Access-SQLServer/SqlDataSource/Part-1/_9.png" width="200" height="247" alt="Query Result on Web Page" title="Query Result on Web Page"  /></a></li></ol><p>Related posts:<ol><li><a
href='http://www.linglom.com/2010/04/02/accessing-sql-server-on-asp-net-web-application-using-sqldatasource-web-control-part-2-update-data/' rel='bookmark' title='Accessing SQL Server on ASP.NET Web Application using SqlDataSource Web Control, Part 2: UPDATE Data'>Accessing SQL Server on ASP.NET Web Application using SqlDataSource Web Control, Part 2: UPDATE Data</a> <small>Accessing SQL Server on ASP.NET Web Application using SqlDataSource Web...</small></li><li><a
href='http://www.linglom.com/2010/04/14/accessing-sql-server-on-asp-net-web-application-using-ado-net/' rel='bookmark' title='Accessing SQL Server on ASP.NET Web Application using ADO.NET'>Accessing SQL Server on ASP.NET Web Application using ADO.NET</a> <small>ADO.NET is a set of components that can be used...</small></li><li><a
href='http://www.linglom.com/2008/08/26/create-dynamic-rss-feed-from-ms-sql-server-using-aspnet-part-i-vbnet/' rel='bookmark' title='Create Dynamic RSS Feed from MS SQL Server using ASP.NET, Part I: VB.NET'>Create Dynamic RSS Feed from MS SQL Server using ASP.NET, Part I: VB.NET</a> <small>Introduction Before I started, let&#8217;s get to know what RSS...</small></li></ol></p>]]></content:encoded> <wfw:commentRss>http://www.linglom.com/2010/03/26/accessing-sql-server-on-asp-net-web-application-using-sqldatasource-web-control-part-1-select-data/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Accessing MS Access 2007 on NetBeans 6.5 using JDBC, Part 4: Perform SQL Operations</title><link>http://www.linglom.com/2009/09/07/accessing-ms-access-2007-on-netbeans-6-5-using-jdbc-part-4-perform-sql-operations/</link> <comments>http://www.linglom.com/2009/09/07/accessing-ms-access-2007-on-netbeans-6-5-using-jdbc-part-4-perform-sql-operations/#comments</comments> <pubDate>Sun, 06 Sep 2009 23:33:19 +0000</pubDate> <dc:creator>linglom</dc:creator> <category><![CDATA[Java]]></category> <category><![CDATA[NetBeans]]></category> <category><![CDATA[Programming]]></category> <category><![CDATA[Access 2007]]></category> <category><![CDATA[JDBC]]></category> <guid
isPermaLink="false">http://www.linglom.com/?p=1032</guid> <description><![CDATA[This article is one of the series of Accessing Access 2007 on NetBeans 6.5 using JDBC. You can see the index of this series at Accessing Access 2007 on NetBeans 6.5 using JDBC, Part 1: Introduction Perform SQL Operations From Part 3: Create a Connection, I show how to create a connection from NetBeans 6.5 [...]
Related posts:<ol><li><a
href='http://www.linglom.com/2008/01/16/accessing-mysql-on-netbeans-using-jdbc-part-ii-perform-sql-operations/' rel='bookmark' title='Accessing MySQL on NetBeans using JDBC, Part II: Perform SQL Operations'>Accessing MySQL on NetBeans using JDBC, Part II: Perform SQL Operations</a> <small>From Part I, I have only established a connection with...</small></li><li><a
href='http://www.linglom.com/2007/07/14/accessing-sql-server-on-netbeans-using-jdbc-part-ii-perform-sql-operations/' rel='bookmark' title='Accessing SQL Server on NetBeans using JDBC, Part II: Perform SQL Operations'>Accessing SQL Server on NetBeans using JDBC, Part II: Perform SQL Operations</a> <small>From Part I, I have only established a connection with...</small></li><li><a
href='http://www.linglom.com/2009/08/24/accessing-ms-access-2007-on-netbeans-6-5-using-jdbc-part-1-introduction/' rel='bookmark' title='Accessing MS Access 2007 on NetBeans 6.5 using JDBC, Part 1: Introduction'>Accessing MS Access 2007 on NetBeans 6.5 using JDBC, Part 1: Introduction</a> <small>Introduction Here comes again, a tutorial about accessing database on...</small></li></ol>]]></description> <content:encoded><![CDATA[<p><a
name="top"></a><br
/> This article is one of the series of Accessing Access 2007 on NetBeans 6.5 using JDBC. You can see the index of this series at <a
href="http://www.linglom.com/2009/08/24/accessing-ms-access-2007-on-netbeans-6-5-using-jdbc-part-1-introduction/">Accessing Access 2007 on NetBeans 6.5 using JDBC, Part 1: Introduction</a></p><p><span
id="more-1032"></span></p><p></p><h3>Perform SQL Operations</h3><p>From <a
href="http://www.linglom.com/2009/08/31/accessing-ms-access-2007-on-netbeans-6-5-using-jdbc-part-3-create-a-connection/">Part 3: Create a Connection</a>, I show how to create a connection from NetBeans 6.5 to the Northwind database of Microsoft Access 2007. On this post, you see how to perform basic SQL operations such as SELECT, INSERT, DELETE and UPDATE to the Customers table on Northwind database.</p><ul><li><a
href="#1">Retrieve data from database</a></li><li><a
href="#2">Update data on database</a></li></ul><p><a
name="1"></a></p><h4>Retrieve data from database</h4><p>Copy and paste the code below on main method between these lines:</p><div
class="wp_syntax"><div
class="code"><pre class="java" style="font-family:monospace;"><span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Connected!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div><p>and</p><div
class="wp_syntax"><div
class="code"><pre class="java" style="font-family:monospace;">con.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div><p><strong>The Code</strong></p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td
class="code"><pre class="java" style="font-family:monospace;">            <span style="color: #003399;">Statement</span> stmt <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
            <span style="color: #003399;">ResultSet</span> rs <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #666666; font-style: italic;">// SQL query command</span>
            <span style="color: #003399;">String</span> SQL <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT * FROM Customers&quot;</span><span style="color: #339933;">;</span>
            stmt <span style="color: #339933;">=</span> con.<span style="color: #006633;">createStatement</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            rs <span style="color: #339933;">=</span> stmt.<span style="color: #006633;">executeQuery</span><span style="color: #009900;">&#40;</span>SQL<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span>rs.<span style="color: #006633;">next</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>rs.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Company&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; : &quot;</span>
                        <span style="color: #339933;">+</span> rs.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;First Name&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; : &quot;</span>
                        <span style="color: #339933;">+</span> rs.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Last Name&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span></pre></td></tr></table></div><p><strong>Code Explanation:</strong></p><ul><li>Line 1-2: Declare some variables.</li><li>Line 5: Define SQL query string.</li><li>Line 6: Create a statement object for sending SQL statements to the database.</li><li>Line 7: Executes the SQL statement and returns a single ResultSet object.</li><li>Line 8-12: Iterative in the ResultSet object to show results on output window</li></ul><p><a
href="http://www.linglom.com/images/Windows/Programming/NetBeans-MSAccess2007/Part-4/1.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/NetBeans-MSAccess2007/Part-4/_1.png" width="200" height="113" alt="Query Code" title="Query Code"  /></a></p><p>Next, run the project. You see the result on the output window. It displays records from Customers table.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/NetBeans-MSAccess2007/Part-4/2.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/NetBeans-MSAccess2007/Part-4/_2.png" width="200" height="313" alt="Query Result" title="Query Result"  /></a><br
/> <a
href="#top">Back to top</a></p><p><a
name="2"></a></p><h4>Update data on database</h4><p>To insert, update and delete records on MS Access 2007 databases, you can re-use the code from the previous section. But you need to replace the SQL statement and code on this line:</p><div
class="wp_syntax"><div
class="code"><pre class="java" style="font-family:monospace;">rs <span style="color: #339933;">=</span> stmt.<span style="color: #006633;">executeQuery</span><span style="color: #009900;">&#40;</span>SQL<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span>rs.<span style="color: #006633;">next</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>rs.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Company&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; : &quot;</span>
                        <span style="color: #339933;">+</span> rs.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;First Name&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; : &quot;</span>
                        <span style="color: #339933;">+</span> rs.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Last Name&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span></pre></div></div><p>to</p><div
class="wp_syntax"><div
class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">int</span> rowsEffected <span style="color: #339933;">=</span> stmt.<span style="color: #006633;">executeUpdate</span><span style="color: #009900;">&#40;</span>SQL<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>rowsEffected <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; rows effected&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div><p><strong>Code Explanation: </strong><br
/> Executes the given SQL statement which may be INSERT, UPDATE or DELETE statement and returns the row count for the update.</p><p><strong>INSERT command</strong></p><div
class="wp_syntax"><div
class="code"><pre class="java" style="font-family:monospace;">            <span style="color: #666666; font-style: italic;">// SQL INSERT command</span>
            <span style="color: #003399;">String</span> SQL <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;INSERT INTO Customers (Company,[First Name],&quot;</span> <span style="color: #339933;">+</span>
                    <span style="color: #0000ff;">&quot;[Last Name]) VALUES ('MyCompany','Linglom','My Last Name')&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">int</span> rowsEffected <span style="color: #339933;">=</span> stmt.<span style="color: #006633;">executeUpdate</span><span style="color: #009900;">&#40;</span>SQL<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>rowsEffected <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; rows effected&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div><p><strong>UPDATE command</strong></p><div
class="wp_syntax"><div
class="code"><pre class="java" style="font-family:monospace;">            <span style="color: #666666; font-style: italic;">// SQL UPDATE command</span>
            <span style="color: #003399;">String</span> SQL <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;UPDATE Customers SET [Last Name] = 'New Last Name'&quot;</span> <span style="color: #339933;">+</span>
                            <span style="color: #0000ff;">&quot;WHERE [First Name] = 'Linglom'&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">int</span> rowsEffected <span style="color: #339933;">=</span> stmt.<span style="color: #006633;">executeUpdate</span><span style="color: #009900;">&#40;</span>SQL<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>rowsEffected <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; rows effected&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div><p><strong>DELETE command</strong></p><div
class="wp_syntax"><div
class="code"><pre class="java" style="font-family:monospace;">            <span style="color: #666666; font-style: italic;">// SQL DELETE command</span>
            <span style="color: #003399;">String</span> SQL <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;DELETE FROM Customers WHERE [First Name] = 'Linglom'&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">int</span> rowsEffected <span style="color: #339933;">=</span> stmt.<span style="color: #006633;">executeUpdate</span><span style="color: #009900;">&#40;</span>SQL<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>rowsEffected <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; rows effected&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div><h3>Summary</h3><p>You can download the source code of this series at <a
href="http://forum.linglom.com/index.php?topic=685.0">SampleAccess2007.java</a>. The example code will create a connection to Northwind database on Microsoft Access 2007. Then, retrieve records, insert a new record, update and delete the record from Customer table. Here is output of the example code.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/NetBeans-MSAccess2007/Part-4/3.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/NetBeans-MSAccess2007/Part-4/_3.png" width="200" height="111" alt="Update Result" title="Update Result"  /></a><br
/> <a
href="#top">Back to top</a></p><p>Related posts:<ol><li><a
href='http://www.linglom.com/2008/01/16/accessing-mysql-on-netbeans-using-jdbc-part-ii-perform-sql-operations/' rel='bookmark' title='Accessing MySQL on NetBeans using JDBC, Part II: Perform SQL Operations'>Accessing MySQL on NetBeans using JDBC, Part II: Perform SQL Operations</a> <small>From Part I, I have only established a connection with...</small></li><li><a
href='http://www.linglom.com/2007/07/14/accessing-sql-server-on-netbeans-using-jdbc-part-ii-perform-sql-operations/' rel='bookmark' title='Accessing SQL Server on NetBeans using JDBC, Part II: Perform SQL Operations'>Accessing SQL Server on NetBeans using JDBC, Part II: Perform SQL Operations</a> <small>From Part I, I have only established a connection with...</small></li><li><a
href='http://www.linglom.com/2009/08/24/accessing-ms-access-2007-on-netbeans-6-5-using-jdbc-part-1-introduction/' rel='bookmark' title='Accessing MS Access 2007 on NetBeans 6.5 using JDBC, Part 1: Introduction'>Accessing MS Access 2007 on NetBeans 6.5 using JDBC, Part 1: Introduction</a> <small>Introduction Here comes again, a tutorial about accessing database on...</small></li></ol></p>]]></content:encoded> <wfw:commentRss>http://www.linglom.com/2009/09/07/accessing-ms-access-2007-on-netbeans-6-5-using-jdbc-part-4-perform-sql-operations/feed/</wfw:commentRss> <slash:comments>21</slash:comments> </item> <item><title>Accessing MS Access 2007 on NetBeans 6.5 using JDBC, Part 3: Create a Connection</title><link>http://www.linglom.com/2009/08/31/accessing-ms-access-2007-on-netbeans-6-5-using-jdbc-part-3-create-a-connection/</link> <comments>http://www.linglom.com/2009/08/31/accessing-ms-access-2007-on-netbeans-6-5-using-jdbc-part-3-create-a-connection/#comments</comments> <pubDate>Mon, 31 Aug 2009 03:45:21 +0000</pubDate> <dc:creator>linglom</dc:creator> <category><![CDATA[Java]]></category> <category><![CDATA[NetBeans]]></category> <category><![CDATA[Programming]]></category> <category><![CDATA[Access 2007]]></category> <category><![CDATA[JDBC]]></category> <guid
isPermaLink="false">http://www.linglom.com/?p=1029</guid> <description><![CDATA[This article is one of the series of Accessing MS Access 2007 on NetBeans 6.5 using JDBC. You can see the index of this series at Accessing Access 2007 on NetBeans 6.5 using JDBC, Part 1: Introduction Create a Connection From Part 2: Prepare Sample Database, I show how to setup Northwind database for Microsoft [...]
Related posts:<ol><li><a
href='http://www.linglom.com/2009/08/24/accessing-ms-access-2007-on-netbeans-6-5-using-jdbc-part-1-introduction/' rel='bookmark' title='Accessing MS Access 2007 on NetBeans 6.5 using JDBC, Part 1: Introduction'>Accessing MS Access 2007 on NetBeans 6.5 using JDBC, Part 1: Introduction</a> <small>Introduction Here comes again, a tutorial about accessing database on...</small></li><li><a
href='http://www.linglom.com/2009/08/27/accessing-ms-access-2007-on-netbeans-6-5-using-jdbc-part-2-prepare-sample-database/' rel='bookmark' title='Accessing MS Access 2007 on NetBeans 6.5 using JDBC, Part 2: Prepare Sample Database'>Accessing MS Access 2007 on NetBeans 6.5 using JDBC, Part 2: Prepare Sample Database</a> <small>This article is one of the series of Accessing MS...</small></li><li><a
href='http://www.linglom.com/2007/03/04/accessing-sql-server-on-netbeans-using-jdbc-part-i-create-a-connection/' rel='bookmark' title='Accessing SQL Server on NetBeans using JDBC, Part I: Create a connection'>Accessing SQL Server on NetBeans using JDBC, Part I: Create a connection</a> <small>Introduction This tutorial show you how to use NetBeans to...</small></li></ol>]]></description> <content:encoded><![CDATA[<p>This article is one of the series of Accessing MS Access 2007 on NetBeans 6.5 using JDBC. You can see the index of this series at <a
href="http://www.linglom.com/2009/08/24/accessing-ms-access-2007-on-netbeans-6-5-using-jdbc-part-1-introduction/">Accessing Access 2007 on NetBeans 6.5 using JDBC, Part 1: Introduction</a></p><p><span
id="more-1029"></span></p><h3>Create a Connection</h3><p>From <a
href="http://www.linglom.com/2009/08/27/accessing-ms-access-2007-on-netbeans-6-5-using-jdbc-part-2-prepare-sample-database/">Part 2: Prepare Sample Database</a>, I show how to setup Northwind database for Microsoft Access 2007. Now let&#8217;s start programming. On this post, you see how to create a connection from NetBeans 6.5 to the Northwind database of Microsoft Access 2007 which located at &#8220;c:\database\Northwind 2007.accdb&#8221;.</p><p></p><h3>Step-by-step</h3><ol><li>Create a new Java Application project on NetBeans. Open NetBeans 6.5.1 and select <strong>File</strong> -> <strong>New Project</strong>.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/NetBeans-MSAccess2007/Part-3/1.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/NetBeans-MSAccess2007/Part-3/_1.png" width="200" height="150" alt="New Project on NetBeans" title="New Project on NetBeans"  /></a></li><li>On <strong>New Project</strong>, select <strong>Java</strong> -> <strong>Java Application</strong>. Click <strong>Next</strong>.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/NetBeans-MSAccess2007/Part-3/2.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/NetBeans-MSAccess2007/Part-3/_2.png" width="200" height="138" alt="Select Java Application" title="Select Java Application"  /></a></li><li>On <strong>New Java Application</strong>, type the project name <strong>&#8220;NorthwindSample&#8221;</strong> and click <strong>Finish</strong>.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/NetBeans-MSAccess2007/Part-3/3.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/NetBeans-MSAccess2007/Part-3/_3.png" width="200" height="129" alt="Type Project Name for New Java Application" title="Type Project Name for New Java Application"  /></a></li><li>The project <strong>&#8220;NorthwindSample&#8221;</strong> is created.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/NetBeans-MSAccess2007/Part-3/4.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/NetBeans-MSAccess2007/Part-3/_4.png" width="200" height="150" alt="NorthwindSample's Project" title="NorthwindSample's Project"  /></a></li><li>Let&#8217;s begin the programming part. First, I need to import some libraries.<div
class="wp_syntax"><div
class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.sql.*</span><span style="color: #339933;">;</span></pre></div></div><p><a
href="http://www.linglom.com/images/Windows/Programming/NetBeans-MSAccess2007/Part-3/5.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/NetBeans-MSAccess2007/Part-3/_5.png" width="200" height="117" alt="Import Libraries" title="Import Libraries"  /></a></li><li>Type the code below to the main method.<div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td
class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">Class</span>.<span style="color: #006633;">forName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;sun.jdbc.odbc.JdbcOdbcDriver&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003399;">String</span> url <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;jdbc:odbc:Driver={Microsoft Access Driver &quot;</span> <span style="color: #339933;">+</span>
            <span style="color: #0000ff;">&quot;(*.mdb, *.accdb)};DBQ=C:<span style="color: #000099; font-weight: bold;">\\</span>Database<span style="color: #000099; font-weight: bold;">\\</span>Northwind 2007.accdb&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #003399;">Connection</span> con <span style="color: #339933;">=</span> <span style="color: #003399;">DriverManager</span>.<span style="color: #006633;">getConnection</span><span style="color: #009900;">&#40;</span>url<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Connected!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        con.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">SQLException</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SQL Exception: &quot;</span><span style="color: #339933;">+</span> e.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">ClassNotFoundException</span> cE<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Class Not Found Exception: &quot;</span><span style="color: #339933;">+</span>
                cE.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span></pre></td></tr></table></div><p><strong>Code Explanation:</strong></p><ul><li><em>Line 2:</em> Class.forName(&#8220;sun.jdbc.odbc.JdbcOdbcDriver&#8221;); means load the JDBC-ODBC driver.</li><li><em>Line 3-4:</em> String url = &#8220;jdbc:odbc:Driver={Microsoft Access Driver &#8221; + &#8220;(*.mdb, *.accdb)};DBQ=C:\\Database\\Northwind 2007.accdb&#8221;; declare a variable which store a string of the driver name for Microsoft Access 2007 and the location of the Northwind database.</li><li><em>Line 5:</em> Make a connection using information on the variable which was created before.</li><li><em>Line 6:</em> Display &#8220;Connected!&#8221; on console window.</li><li><em>Line 7:</em> Close the connection.</li></ul><p><a
href="http://www.linglom.com/images/Windows/Programming/NetBeans-MSAccess2007/Part-3/6.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/NetBeans-MSAccess2007/Part-3/_6.png" width="200" height="112" alt="Code to Connect To MS Access 2007" title="Code to Connect To MS Access 2007"  /></a></li><li>Compile and run the project. You see the text <strong>&#8220;Connected!&#8221;</strong> on the output window. Otherwise, you should see an exception message.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/NetBeans-MSAccess2007/Part-3/7.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/NetBeans-MSAccess2007/Part-3/_7.png" width="200" height="84" alt="Connected to MS Access 2007's Database" title="Connected to MS Access 2007's Database"  /></a></li></ol><h3>What&#8217;s Next?</h3><p>Now you have connected to the Northwind database of Microsoft Access 2007. Next, I will show how to perform some basic SQL operations such as SELECT, INSERT, UPDATE and DELETE to the Northwind database. See <a
href="http://www.linglom.com/2009/09/07/accessing-ms-access-2007-on-netbeans-6-5-using-jdbc-part-4-perform-sql-operations/">Part 4: Perform SQL Operations</a>.</p><p>Related posts:<ol><li><a
href='http://www.linglom.com/2009/08/24/accessing-ms-access-2007-on-netbeans-6-5-using-jdbc-part-1-introduction/' rel='bookmark' title='Accessing MS Access 2007 on NetBeans 6.5 using JDBC, Part 1: Introduction'>Accessing MS Access 2007 on NetBeans 6.5 using JDBC, Part 1: Introduction</a> <small>Introduction Here comes again, a tutorial about accessing database on...</small></li><li><a
href='http://www.linglom.com/2009/08/27/accessing-ms-access-2007-on-netbeans-6-5-using-jdbc-part-2-prepare-sample-database/' rel='bookmark' title='Accessing MS Access 2007 on NetBeans 6.5 using JDBC, Part 2: Prepare Sample Database'>Accessing MS Access 2007 on NetBeans 6.5 using JDBC, Part 2: Prepare Sample Database</a> <small>This article is one of the series of Accessing MS...</small></li><li><a
href='http://www.linglom.com/2007/03/04/accessing-sql-server-on-netbeans-using-jdbc-part-i-create-a-connection/' rel='bookmark' title='Accessing SQL Server on NetBeans using JDBC, Part I: Create a connection'>Accessing SQL Server on NetBeans using JDBC, Part I: Create a connection</a> <small>Introduction This tutorial show you how to use NetBeans to...</small></li></ol></p>]]></content:encoded> <wfw:commentRss>http://www.linglom.com/2009/08/31/accessing-ms-access-2007-on-netbeans-6-5-using-jdbc-part-3-create-a-connection/feed/</wfw:commentRss> <slash:comments>46</slash:comments> </item> <item><title>Accessing MS Access 2007 on NetBeans 6.5 using JDBC, Part 2: Prepare Sample Database</title><link>http://www.linglom.com/2009/08/27/accessing-ms-access-2007-on-netbeans-6-5-using-jdbc-part-2-prepare-sample-database/</link> <comments>http://www.linglom.com/2009/08/27/accessing-ms-access-2007-on-netbeans-6-5-using-jdbc-part-2-prepare-sample-database/#comments</comments> <pubDate>Thu, 27 Aug 2009 04:02:06 +0000</pubDate> <dc:creator>linglom</dc:creator> <category><![CDATA[Java]]></category> <category><![CDATA[NetBeans]]></category> <category><![CDATA[Programming]]></category> <category><![CDATA[Access 2007]]></category> <category><![CDATA[JDBC]]></category> <guid
isPermaLink="false">http://www.linglom.com/?p=1023</guid> <description><![CDATA[This article is one of the series of Accessing MS Access 2007 on NetBeans 6.5 using JDBC. You can see the index of this series at Accessing Access 2007 on NetBeans 6.5 using JDBC, Part 1: Introduction Prepare Sample Database On this post, I show how to prepare a sample database for Microsoft Access 2007, [...]
Related posts:<ol><li><a
href='http://www.linglom.com/2009/08/24/accessing-ms-access-2007-on-netbeans-6-5-using-jdbc-part-1-introduction/' rel='bookmark' title='Accessing MS Access 2007 on NetBeans 6.5 using JDBC, Part 1: Introduction'>Accessing MS Access 2007 on NetBeans 6.5 using JDBC, Part 1: Introduction</a> <small>Introduction Here comes again, a tutorial about accessing database on...</small></li><li><a
href='http://www.linglom.com/2009/08/31/accessing-ms-access-2007-on-netbeans-6-5-using-jdbc-part-3-create-a-connection/' rel='bookmark' title='Accessing MS Access 2007 on NetBeans 6.5 using JDBC, Part 3: Create a Connection'>Accessing MS Access 2007 on NetBeans 6.5 using JDBC, Part 3: Create a Connection</a> <small>This article is one of the series of Accessing MS...</small></li><li><a
href='http://www.linglom.com/2009/09/07/accessing-ms-access-2007-on-netbeans-6-5-using-jdbc-part-4-perform-sql-operations/' rel='bookmark' title='Accessing MS Access 2007 on NetBeans 6.5 using JDBC, Part 4: Perform SQL Operations'>Accessing MS Access 2007 on NetBeans 6.5 using JDBC, Part 4: Perform SQL Operations</a> <small>This article is one of the series of Accessing Access...</small></li></ol>]]></description> <content:encoded><![CDATA[<p>This article is one of the series of Accessing MS Access 2007 on NetBeans 6.5 using JDBC. You can see the index of this series at <a
href="http://www.linglom.com/2009/08/24/accessing-ms-access-2007-on-netbeans-6-5-using-jdbc-part-1-introduction/">Accessing Access 2007 on NetBeans 6.5 using JDBC, Part 1: Introduction</a></p><p><span
id="more-1023"></span></p><h3>Prepare Sample Database</h3><p>On this post, I show how to prepare a sample database for Microsoft Access 2007, the <strong>&#8220;Northwind&#8221;</strong> database.</p><p></p><h3>Step-by-step</h3><ol><li>Open Microsoft Access 2007, click on <strong>Local Templates</strong>. If you have <strong>Northwind 2007</strong> on <strong>Local Templates</strong>, click on it and skip to step 4. Otherwise, follow the next step to download one.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/NetBeans-MSAccess2007/Part-2/1.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/NetBeans-MSAccess2007/Part-2/_1.png" width="200" height="140" alt="Northwind 2007 on Local Templates" title="Northwind 2007 on Local Templates"  /></a></li><li>Download Northwind template for Access 2007 from Microsoft &#8211; <a
href="http://office.microsoft.com/en-us/templates/TC012289971033.aspx?CategoryID=CT101428651033" target="_blank" rel="nofollow">Northwind 2007</a>.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/NetBeans-MSAccess2007/Part-2/2.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/NetBeans-MSAccess2007/Part-2/_2.png" width="200" height="261" alt="Download Northwind template for Access 2007" title="Download Northwind template for Access 2007"  /></a></li><li>Extract the downloaded file, 01228997.cab. Then, double-click on <strong>01228997.accdt</strong>. Microsoft Office Access 2007 will start.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/NetBeans-MSAccess2007/Part-2/3.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/NetBeans-MSAccess2007/Part-2/_3.png" width="200" height="145" alt="Northwind 2007" title="Northwind 2007"  /></a></li><li>On <strong>Microsoft Access</strong>, choose the destination to create a sample Northwind 2007. On this example, I choose <strong>&#8220;c:\database\Northwind 2007.accdb&#8221;</strong>. Then, click <strong>Create</strong>.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/NetBeans-MSAccess2007/Part-2/4.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/NetBeans-MSAccess2007/Part-2/_4.png" width="200" height="144" alt="Create sample Northwind database for Microsoft Access 2007" title="Create sample Northwind database for Microsoft Access 2007"  /></a></li><li>Now the sample Northwind database is created. Click on <strong>Navigation Pane</strong> on the left side menu.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/NetBeans-MSAccess2007/Part-2/5.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/NetBeans-MSAccess2007/Part-2/_5.png" width="200" height="144" alt="Northwind Sample Database" title="Northwind Sample Database"  /></a></li><li>On <strong>Navigation Pane</strong>, click on <strong>Supporting Objects</strong> and double-click on <strong>Customers</strong>. You see data in the Customers table.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/NetBeans-MSAccess2007/Part-2/6.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/NetBeans-MSAccess2007/Part-2/_6.png" width="200" height="144" alt="View Sample Data" title="View Sample Data"  /></a></li><li>You also see the sample database file on <strong>c:\database\Northwind 2007.accdb</strong> which was created on step 4. I will use this path in the later part.<br
/> <a
href="http://www.linglom.com/images/Windows/Programming/NetBeans-MSAccess2007/Part-2/7.png" target="_blank"><img
src="http://www.linglom.com/images/Windows/Programming/NetBeans-MSAccess2007/Part-2/_7.png" width="200" height="150" alt="Northwind 2007.accdb" title="Northwind 2007.accdb"  /></a></li></ol><h3>What&#8217;s Next?</h3><p>Now you have a sample database, Northwind. Next, I will show how to write code to create a connection from NetBeans 6.5 to the Northwind database. See <a
href="http://www.linglom.com/2009/08/31/accessing-ms-access-2007-on-netbeans-6-5-using-jdbc-part-3-create-a-connection/">Part 3: Create a Connection</a>.</p><p>Related posts:<ol><li><a
href='http://www.linglom.com/2009/08/24/accessing-ms-access-2007-on-netbeans-6-5-using-jdbc-part-1-introduction/' rel='bookmark' title='Accessing MS Access 2007 on NetBeans 6.5 using JDBC, Part 1: Introduction'>Accessing MS Access 2007 on NetBeans 6.5 using JDBC, Part 1: Introduction</a> <small>Introduction Here comes again, a tutorial about accessing database on...</small></li><li><a
href='http://www.linglom.com/2009/08/31/accessing-ms-access-2007-on-netbeans-6-5-using-jdbc-part-3-create-a-connection/' rel='bookmark' title='Accessing MS Access 2007 on NetBeans 6.5 using JDBC, Part 3: Create a Connection'>Accessing MS Access 2007 on NetBeans 6.5 using JDBC, Part 3: Create a Connection</a> <small>This article is one of the series of Accessing MS...</small></li><li><a
href='http://www.linglom.com/2009/09/07/accessing-ms-access-2007-on-netbeans-6-5-using-jdbc-part-4-perform-sql-operations/' rel='bookmark' title='Accessing MS Access 2007 on NetBeans 6.5 using JDBC, Part 4: Perform SQL Operations'>Accessing MS Access 2007 on NetBeans 6.5 using JDBC, Part 4: Perform SQL Operations</a> <small>This article is one of the series of Accessing Access...</small></li></ol></p>]]></content:encoded> <wfw:commentRss>http://www.linglom.com/2009/08/27/accessing-ms-access-2007-on-netbeans-6-5-using-jdbc-part-2-prepare-sample-database/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: basic
Database Caching 8/87 queries in 0.060 seconds using disk: basic
Content Delivery Network via cdn.linglom.com/linglom

Served from: www.linglom.com @ 2012-02-05 04:07:00 -->
