<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-7940058950332398351</id><updated>2024-09-15T17:52:01.658-07:00</updated><title type='text'>Gambas data grid code</title><subtitle type='html'>Gambas source code.Gambas datagrid, gambas sample programs. Edit gambas data grid-mysql. Gambas-stock control programs. Gambas datagrid sample, gambas get text and gambas get text-mysql</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://gambas-data-grid-codes-database.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7940058950332398351/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://gambas-data-grid-codes-database.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Allsearchengines.blogspot.com</name><uri>http://www.blogger.com/profile/11174269673917299671</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDdRnmNEk1Cp57AEcyvDr0xIJUe31vfRyGDqSRrBTu4iWfHkMJOy6wDjAkD4kbsGlkUggE6ftsFne7EGiSX-0a2VqNGHX0VQbPkVeENtRbworeumQhmIVi4S9fjgifgLs/s220/25299_1188449160606_1509634281_30384185_4723363_a.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>6</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7940058950332398351.post-8966843755378605667</id><published>2012-10-03T08:01:00.001-07:00</published><updated>2012-10-03T08:01:21.669-07:00</updated><title type='text'>Add data to a gambas data grid</title><content type='html'>&lt;b&gt;Data grid Codes&lt;/b&gt;&lt;br /&gt;
&amp;nbsp;This event is raised when the GridView needs the data stored in a specified cell.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; * Row is the cell row.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; * Column is the cell column.&lt;br /&gt;
&lt;br /&gt;
PUBLIC SUB GridView1_Data(Row AS Integer, Column AS Integer)&lt;br /&gt;
GridView1.Data.Text = &quot;Gambas &quot; &amp;amp; Row &amp;amp; &quot;,&quot; &amp;amp; Column&lt;br /&gt;
END&lt;br /&gt;
&lt;h1&gt;
Adding new records in a Gambas data grid&lt;/h1&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;&#39; Gambas class file&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;PRIVATE $hConn AS NEW 
Connection&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;PRIVATE $res AS Result&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;&#39;-------------------------------------------------&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;PUBLIC SUB Form_Open()&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;DIM iCount AS Integer&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;DIM hTable AS Table&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;DIM rTest AS result&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;DIM sql AS String&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;&#39;define the gridview layout&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;GridView1.header = 
GridView.Horizontal&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;GridView1.grid = TRUE&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;GridView1.Rows.count = 0&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;GridView1.Columns.count = 2&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;GridView1.Columns[0].text = 
&quot;ID&quot;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;GridView1.Columns[1].text = &quot;Value&quot;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;GridView1.Columns[0].width = 
55&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;GridView1.Columns[1].width = 55&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;WITH $hConn&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain 
plain&quot;&gt;.Type = &quot;sqlite&quot;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain 
plain&quot;&gt;.host = User.home&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain 
plain&quot;&gt;.name = &quot;&quot;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line
 alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;END WITH&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;&#39;delete an existing test.sqlite&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;IF Exist(User.home &amp;amp; 
&quot;/test.sqlite&quot;) THEN&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain 
plain&quot;&gt;KILL User.home &amp;amp; &quot;/test.sqlite&quot;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;ENDIF&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;&#39;create test.sqlite&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;$hConn.Open&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain 
plain&quot;&gt;$hConn.Databases.Add(&quot;test.sqlite&quot;)&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;$hconn.Close&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;&#39;define the table sampleTable&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;$hconn.name = &quot;test.sqlite&quot;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;$hConn.Open&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain 
plain&quot;&gt;hTable = $hConn.Tables.Add(&quot;sampleTable&quot;)&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain 
plain&quot;&gt;hTable.Fields.Add(&quot;s_seq&quot;, db.Integer)&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain 
plain&quot;&gt;hTable.Fields.Add(&quot;s_rndm&quot;, db.Integer)&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain 
plain&quot;&gt;hTable.PrimaryKey = [&quot;s_seq&quot;]&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain 
plain&quot;&gt;hTable.Update&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;&#39;fill the table with generated data&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;$hconn.Begin&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain 
plain&quot;&gt;rTest = $hConn.Create(&quot;sampleTable&quot;)&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain 
plain&quot;&gt;FOR iCount = 1 TO 10000&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain 
plain&quot;&gt;rTest!s_seq = iCount&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain 
plain&quot;&gt;rTest!s_rndm = Int(Rnd(0, 100))&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain 
plain&quot;&gt;rTest.Update&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain 
plain&quot;&gt;NEXT&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;$hConn.Commit&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;&#39;read the database&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;sql = &quot;select s_seq as ID, 
s_rndm as Value from sampleTable&quot;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;$res = $hconn.Exec(sql)&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;CATCH&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;$hConn.Rollback&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;Message.Error(DConv(Error.Text))&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;
&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;END&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;
&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;&#39;-------------------------------------------------&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;
&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;PUBLIC SUB Form_Activate()&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;
&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;&#39;change the rowcount of the 
gridview from 0 to the number of records.&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;
&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;&#39;This triggers the data 
handling event&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line 
alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;
&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;
&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;GridView1.Rows.Count = $res.Count&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;
&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;END&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;
&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;&#39;-------------------------------------------------&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;
&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;PUBLIC SUB GridView1_Data(Row
 AS Integer, Column AS Integer)&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;
&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/code&gt;&lt;code class=&quot;plain 
plain&quot;&gt;$res.moveTo(row)&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;
&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/code&gt;&lt;code class=&quot;plain 
plain&quot;&gt;GridView1.Data.text = Str($res[GridView1.Columns[column].text])&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;
&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;END&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;
&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;&#39;-------------------------------------------------&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;
&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;PUBLIC SUB Form_Close()&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;
&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain 
plain&quot;&gt;$hconn.Close&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;
&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;END&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
</content><link rel='replies' type='application/atom+xml' href='http://gambas-data-grid-codes-database.blogspot.com/feeds/8966843755378605667/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gambas-data-grid-codes-database.blogspot.com/2012/10/add-data-to-gambas-data-grid.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7940058950332398351/posts/default/8966843755378605667'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7940058950332398351/posts/default/8966843755378605667'/><link rel='alternate' type='text/html' href='http://gambas-data-grid-codes-database.blogspot.com/2012/10/add-data-to-gambas-data-grid.html' title='Add data to a gambas data grid'/><author><name>Allsearchengines.blogspot.com</name><uri>http://www.blogger.com/profile/11174269673917299671</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDdRnmNEk1Cp57AEcyvDr0xIJUe31vfRyGDqSRrBTu4iWfHkMJOy6wDjAkD4kbsGlkUggE6ftsFne7EGiSX-0a2VqNGHX0VQbPkVeENtRbworeumQhmIVi4S9fjgifgLs/s220/25299_1188449160606_1509634281_30384185_4723363_a.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7940058950332398351.post-6194009271311429821</id><published>2012-04-17T09:55:00.000-07:00</published><updated>2012-04-17T09:55:09.455-07:00</updated><title type='text'>Gambas mysql</title><content type='html'>&lt;h2&gt;Mysql Gambas db connection&lt;/h2&gt;property is null, a database is opened in memory.&amp;nbsp;&amp;nbsp; If the Name specified is an&lt;br /&gt;
absolute path, the pathname is used.&amp;nbsp; If the Name specified is a relative path and&lt;br /&gt;
the Host property is null, the database is located&amp;nbsp; in the application temporary&lt;br /&gt;
directory&amp;nbsp; /tmp/gambas.$UID/sqlite.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Otherwise,&amp;nbsp;&amp;nbsp; Host&amp;nbsp;&amp;nbsp; will&amp;nbsp;&amp;nbsp; contain&amp;nbsp;&amp;nbsp; the&amp;nbsp;&amp;nbsp; database&lt;br /&gt;
directory name and the database file path is the result of concatenating the Host&lt;br /&gt;
and Name property values.&amp;nbsp; This class is creatable and the calling convention is:&lt;br /&gt;
&lt;br /&gt;
DIM hConnection AS Connection&lt;br /&gt;
hConnection = NEW Connection() &lt;br /&gt;
Connection Properties&lt;br /&gt;
When&amp;nbsp;&amp;nbsp; the&amp;nbsp; hConnection&amp;nbsp; object&amp;nbsp;&amp;nbsp; is&amp;nbsp;&amp;nbsp; instantiated,&amp;nbsp;&amp;nbsp; it&amp;nbsp;&amp;nbsp; creates&amp;nbsp;&amp;nbsp; a&amp;nbsp;&amp;nbsp; new&amp;nbsp;&amp;nbsp; void&lt;br /&gt;
connection&amp;nbsp;&amp;nbsp; object.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; You&amp;nbsp;&amp;nbsp; will&amp;nbsp;&amp;nbsp; then&amp;nbsp;&amp;nbsp; need&amp;nbsp;&amp;nbsp; to&amp;nbsp;&amp;nbsp; set&amp;nbsp;&amp;nbsp; properties&amp;nbsp;&amp;nbsp; for&amp;nbsp;&amp;nbsp; this&amp;nbsp;&amp;nbsp; object.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The&lt;br /&gt;
properties that you can use with a connection object include Charset, Databases,&lt;br /&gt;
Host, Login, Password, Name, Port, Tables, Type, Users and&amp;nbsp; Version.&amp;nbsp;&amp;nbsp; We will&lt;br /&gt;
explain each of these in the following sections.&lt;br /&gt;
Charset&lt;br /&gt;
Charset&amp;nbsp;&amp;nbsp; is&amp;nbsp;&amp;nbsp; a&amp;nbsp;&amp;nbsp; read­only&amp;nbsp;&amp;nbsp; property&amp;nbsp;&amp;nbsp; that&amp;nbsp;&amp;nbsp; returns&amp;nbsp;&amp;nbsp; the&amp;nbsp;&amp;nbsp; charset&amp;nbsp;&amp;nbsp; used&amp;nbsp;&amp;nbsp; by&amp;nbsp;&amp;nbsp; the&lt;br /&gt;
database.&amp;nbsp;&amp;nbsp; It is possible for you to store your strings in the database directly in&lt;br /&gt;
UTF­8 format.&amp;nbsp;&amp;nbsp; However, you can also can use this property combined with the&lt;br /&gt;
Conv$() subroutine to convert from UTF­8 format to the database charset format.&lt;br /&gt;
Using&amp;nbsp;&amp;nbsp; the&amp;nbsp;&amp;nbsp; database&amp;nbsp;&amp;nbsp; charset&amp;nbsp;&amp;nbsp; comes&amp;nbsp;&amp;nbsp; at&amp;nbsp;&amp;nbsp; a&amp;nbsp;&amp;nbsp; cost&amp;nbsp;&amp;nbsp; in&amp;nbsp;&amp;nbsp; performance&amp;nbsp;&amp;nbsp; however.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; This&amp;nbsp;&amp;nbsp; is&lt;br /&gt;
because you must use the Conv$() subroutine each and every time you read or&lt;br /&gt;
write string data to the database fields.&amp;nbsp; For now, this is the only way you can do&lt;br /&gt;
this if you want to use the string­based SQL functions and built­in sort routines of&lt;br /&gt;
the underlying&amp;nbsp; database management system (MySQL, PostgreSQL, or SQLite).&lt;br /&gt;
Future&amp;nbsp;&amp;nbsp; versions&amp;nbsp;&amp;nbsp; of&amp;nbsp;&amp;nbsp; Gambas&amp;nbsp; may&amp;nbsp; automatically&amp;nbsp;&amp;nbsp; make&amp;nbsp;&amp;nbsp; the&amp;nbsp;&amp;nbsp; conversion&amp;nbsp;&amp;nbsp; between&lt;br /&gt;
Gambas strings and the database charset.&lt;br /&gt;
Databases&lt;br /&gt;
The&amp;nbsp; Databases property&amp;nbsp; can be checked to obtain a collection object that&lt;br /&gt;
will&amp;nbsp;&amp;nbsp; contain&amp;nbsp; names&amp;nbsp; of&amp;nbsp; all&amp;nbsp;&amp;nbsp; databases&amp;nbsp;&amp;nbsp; that&amp;nbsp; are&amp;nbsp;&amp;nbsp; managed&amp;nbsp;&amp;nbsp; by&amp;nbsp;&amp;nbsp; the&amp;nbsp;&amp;nbsp; database&amp;nbsp;&amp;nbsp; server.&lt;br /&gt;
Syntax is:&lt;br /&gt;
PROPERTY Databases AS .ConnectionDatabases &lt;br /&gt;
The&amp;nbsp;&amp;nbsp; resulting&amp;nbsp;&amp;nbsp; collection&amp;nbsp;&amp;nbsp; of&amp;nbsp;&amp;nbsp; data&amp;nbsp;&amp;nbsp; (which&amp;nbsp;&amp;nbsp; is&amp;nbsp;&amp;nbsp; enumerable&amp;nbsp;&amp;nbsp; using&amp;nbsp;&amp;nbsp; the&amp;nbsp;&amp;nbsp; FOR&amp;nbsp;&amp;nbsp; EACH&lt;br /&gt;
328&lt;br /&gt;
A Beginner&#39;s Guide to Gambas&lt;br /&gt;
statement) would be the same as if you typed SHOW DATABASES from the mysql&lt;br /&gt;
client CLI.&lt;br /&gt;
&lt;br /&gt;
Host&lt;br /&gt;
You can use the&amp;nbsp; Host property&amp;nbsp; to set or get the host name of where the&lt;br /&gt;
database server is located.&amp;nbsp; The host name can be either a machine name or an IP&lt;br /&gt;
address.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The&amp;nbsp;&amp;nbsp; default&amp;nbsp;&amp;nbsp; host&amp;nbsp;&amp;nbsp; is&amp;nbsp;&amp;nbsp; named&amp;nbsp;&amp;nbsp; localhost.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; In&amp;nbsp;&amp;nbsp; SQLite,&amp;nbsp;&amp;nbsp; host&amp;nbsp;&amp;nbsp; name&amp;nbsp;&amp;nbsp; is&amp;nbsp;&amp;nbsp; not&lt;br /&gt;
relevant&amp;nbsp;&amp;nbsp; since&amp;nbsp;&amp;nbsp; SQLite&amp;nbsp;&amp;nbsp; is&amp;nbsp;&amp;nbsp; not&amp;nbsp;&amp;nbsp; a&amp;nbsp;&amp;nbsp; client/server&amp;nbsp;&amp;nbsp; database&amp;nbsp;&amp;nbsp; sytstem.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; However,&amp;nbsp;&amp;nbsp; from&lt;br /&gt;
version 0.95 forward, it is possible for you to set the home path for the SQLite&lt;br /&gt;
database by using this property.&amp;nbsp; Syntax for using the Host property is:&lt;br /&gt;
PROPERTY Host AS String &lt;br /&gt;
Login&lt;br /&gt;
The Login property is used to set or get the user login data that is used for&lt;br /&gt;
establishing the connection to the database.&amp;nbsp;&amp;nbsp; Once again, this applies to MySQL&lt;br /&gt;
and PostgreSQL, not SQLite.&amp;nbsp;&amp;nbsp; Since SQLite has no concept of users, access to a&lt;br /&gt;
SQLite database is controlled by the file permission settings of the database file&lt;br /&gt;
itself.&amp;nbsp; This means that the Login property is always going to be set to the user id&lt;br /&gt;
of the user that is executing the Gambas program that uses the SQLite database.&lt;br /&gt;
Syntax is:&lt;br /&gt;
PROPERTY Login AS String &lt;br /&gt;
Name&lt;br /&gt;
The&amp;nbsp; Name&amp;nbsp; property&amp;nbsp; sets or&amp;nbsp;&amp;nbsp; gets&amp;nbsp; the&amp;nbsp; name&amp;nbsp;&amp;nbsp; of&amp;nbsp;&amp;nbsp; the&amp;nbsp;&amp;nbsp; database&amp;nbsp;&amp;nbsp; you&amp;nbsp;&amp;nbsp; want&amp;nbsp;&amp;nbsp; to&lt;br /&gt;
connect to.&amp;nbsp; If you do not specify a name, a default system database is used.&amp;nbsp; For&lt;br /&gt;
PostgreSQL the default database is named&amp;nbsp; template1 and for mySQL it is named&lt;br /&gt;
mysql.&amp;nbsp; For SQLite, the default name is /tmp/sqlite.db.&amp;nbsp; For any database access,&lt;br /&gt;
however, the user needs to have at least read and connect access privileges to use&lt;br /&gt;
these&amp;nbsp; databases.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Sqlite&amp;nbsp;&amp;nbsp; will&amp;nbsp;&amp;nbsp; locate&amp;nbsp; the&amp;nbsp;&amp;nbsp; database&amp;nbsp; first&amp;nbsp; by&amp;nbsp; trying&amp;nbsp;&amp;nbsp; to&amp;nbsp; use&amp;nbsp;&amp;nbsp; the&amp;nbsp; full&lt;br /&gt;
pathname if it has been given.&amp;nbsp; If not, it will check to see if the Host variable has&lt;br /&gt;
been set.&amp;nbsp; If that is the case, SQLite will look at the path name that was set in the&lt;br /&gt;
variable.&amp;nbsp; If the environment variable GAMBAS_SQLITE_DBHOME has been set,&lt;br /&gt;
then SQLite will use that as the current working directory.&amp;nbsp; It is also possible to&lt;br /&gt;
create&amp;nbsp;&amp;nbsp; and&amp;nbsp;&amp;nbsp; use&amp;nbsp;&amp;nbsp; a&amp;nbsp;&amp;nbsp; database&amp;nbsp;&amp;nbsp; in&amp;nbsp;&amp;nbsp; memory&amp;nbsp;&amp;nbsp; by&amp;nbsp;&amp;nbsp; setting&amp;nbsp;&amp;nbsp; the&amp;nbsp;&amp;nbsp; Name&amp;nbsp;&amp;nbsp; property&amp;nbsp;&amp;nbsp; to&lt;br /&gt;
“:memory:” rather than “mysql” or “postgresql” or “sqlite”.&amp;nbsp; Syntax is:&lt;br /&gt;
329&lt;br /&gt;
&lt;br /&gt;
PROPERTY Name AS String &lt;br /&gt;
Password&lt;br /&gt;
The Password property will return or set the password used for establishing&lt;br /&gt;
a connection to the database.&amp;nbsp; Calling convention is:&lt;br /&gt;
PROPERTY Password AS String &lt;br /&gt;
Port&lt;br /&gt;
The Port property is used to get or set the TCP/IP port used for establishing&lt;br /&gt;
the connection to a database.&amp;nbsp; The default port depends on the connection Type.&lt;br /&gt;
Syntax is:&lt;br /&gt;
PROPERTY Port AS String &lt;br /&gt;
Tables&lt;br /&gt;
The Tables property is used to obtain a virtual collection that can be used&lt;br /&gt;
for managing all of the tables of a database.&amp;nbsp; Syntax is:&lt;br /&gt;
PROPERTY Tables AS .ConnectionTables &lt;br /&gt;
Type&lt;br /&gt;
The Type property represents the type of the database server you want to&lt;br /&gt;
connect to.&amp;nbsp;&amp;nbsp; In Gambas, the currently supported databasetype are: &quot;postgresql&quot;,&lt;br /&gt;
&quot;mysql&quot;, and &quot;sqlite&quot;.&amp;nbsp; The type property uses this syntax:&lt;br /&gt;
PROPERTY Type AS String &lt;br /&gt;
Users&lt;br /&gt;
The&amp;nbsp; Users&amp;nbsp;&amp;nbsp; property&amp;nbsp; returns&amp;nbsp;&amp;nbsp; a&amp;nbsp;&amp;nbsp; collection&amp;nbsp;&amp;nbsp; of&amp;nbsp;&amp;nbsp; all&amp;nbsp;&amp;nbsp; users&amp;nbsp;&amp;nbsp; registered&amp;nbsp;&amp;nbsp; in&amp;nbsp;&amp;nbsp; the&lt;br /&gt;
database server.&amp;nbsp; Like any other collection object, it can be enumerated with FOR&lt;br /&gt;
EACH.&amp;nbsp; Syntax is:&lt;br /&gt;
PROPERTY Users AS .ConnectionUsers &lt;br /&gt;
Version&lt;br /&gt;
&lt;br /&gt;
The&amp;nbsp; Version property&amp;nbsp; is a read­only value that returns the version of the&lt;br /&gt;
330&lt;br /&gt;
A Beginner&#39;s Guide to Gambas&lt;br /&gt;
database that the driver has connected with.&amp;nbsp; Syntax is:&lt;br /&gt;
PROPERTY READ Version AS Integer &lt;br /&gt;
The Concept of a Transaction&lt;br /&gt;
There are times when the order in which database actions (or queries) are&lt;br /&gt;
executed is important.&amp;nbsp; Sometimes, a program must ensure all queries in a group&lt;br /&gt;
are run successfully and in order or process none of them at all.&amp;nbsp; A classic example&lt;br /&gt;
is&amp;nbsp;&amp;nbsp; taken&amp;nbsp;&amp;nbsp; from&amp;nbsp;&amp;nbsp; the&amp;nbsp;&amp;nbsp; banking&amp;nbsp;&amp;nbsp; environment.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If&amp;nbsp;&amp;nbsp; a&amp;nbsp;&amp;nbsp; given&amp;nbsp;&amp;nbsp; amount&amp;nbsp;&amp;nbsp; of&amp;nbsp;&amp;nbsp; money&amp;nbsp;&amp;nbsp; (for&lt;br /&gt;
example, 100 dollars) is taken from one account and posted to another account,&lt;br /&gt;
we would expect the following actions to occur:&lt;br /&gt;
UPDATE account1 SET balance = balance ­ 100;&lt;br /&gt;
UPDATE account2 SET balance = balance + 100;&lt;br /&gt;
Both queries must execute successfully or neither must execute.&amp;nbsp;&amp;nbsp; Money&lt;br /&gt;
cannot&amp;nbsp;&amp;nbsp; be&amp;nbsp;&amp;nbsp; transferred&amp;nbsp;&amp;nbsp; out&amp;nbsp;&amp;nbsp; of&amp;nbsp;&amp;nbsp; one&amp;nbsp;&amp;nbsp; account&amp;nbsp;&amp;nbsp; and&amp;nbsp;&amp;nbsp; fail&amp;nbsp;&amp;nbsp; to&amp;nbsp;&amp;nbsp; be&amp;nbsp;&amp;nbsp; posted&amp;nbsp;&amp;nbsp; to&amp;nbsp;&amp;nbsp; the&amp;nbsp;&amp;nbsp; other&lt;br /&gt;
account.&amp;nbsp; Both of these queries form a single transaction that is composed of two&lt;br /&gt;
separate&amp;nbsp;&amp;nbsp; actions&amp;nbsp;&amp;nbsp; (debit&amp;nbsp;&amp;nbsp; 100&amp;nbsp;&amp;nbsp; from&amp;nbsp;&amp;nbsp; account1&amp;nbsp;&amp;nbsp; and&amp;nbsp;&amp;nbsp; credit&amp;nbsp;&amp;nbsp; 100&amp;nbsp;&amp;nbsp; to&amp;nbsp;&amp;nbsp; account2).&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A&lt;br /&gt;
transaction&amp;nbsp; is simply one or more individual database queries grouped together&lt;br /&gt;
between&amp;nbsp; BEGIN&amp;nbsp; and&amp;nbsp; COMMIT&amp;nbsp; statements.&amp;nbsp;&amp;nbsp; Without a COMMIT statement, the&lt;br /&gt;
transaction is not permanent and can be reversed with the ROLLBACK statement.&lt;br /&gt;
MySQL automatically commits statements that are not part of a transaction&lt;br /&gt;
process.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The&amp;nbsp;&amp;nbsp; results&amp;nbsp;&amp;nbsp; of&amp;nbsp;&amp;nbsp; any&amp;nbsp;&amp;nbsp; SQL&amp;nbsp;&amp;nbsp; UPDATE&amp;nbsp;&amp;nbsp; or&amp;nbsp;&amp;nbsp; INSERT&amp;nbsp;&amp;nbsp; statement&amp;nbsp;&amp;nbsp; that&amp;nbsp;&amp;nbsp; is&amp;nbsp;&amp;nbsp; not&lt;br /&gt;
preceded&amp;nbsp;&amp;nbsp; with&amp;nbsp;&amp;nbsp; BEGIN&amp;nbsp;&amp;nbsp; will&amp;nbsp;&amp;nbsp; immediately&amp;nbsp;&amp;nbsp; be&amp;nbsp;&amp;nbsp; visible&amp;nbsp;&amp;nbsp; to&amp;nbsp;&amp;nbsp; all&amp;nbsp;&amp;nbsp; connections&amp;nbsp;&amp;nbsp; to&amp;nbsp;&amp;nbsp; the&lt;br /&gt;
database&amp;nbsp;&amp;nbsp; because&amp;nbsp;&amp;nbsp; the&amp;nbsp;&amp;nbsp; commit&amp;nbsp;&amp;nbsp; is&amp;nbsp;&amp;nbsp; automatically&amp;nbsp;&amp;nbsp; performed.&amp;nbsp;&amp;nbsp;&amp;nbsp; Within&amp;nbsp;&amp;nbsp; MySQL,&lt;br /&gt;
transactions are only known with “transaction safe” tables (i.e., BDB and InnoDB).&lt;br /&gt;
The&amp;nbsp; other&amp;nbsp; table&amp;nbsp; types&amp;nbsp; COMMIT&amp;nbsp;&amp;nbsp; immediately.&amp;nbsp;&amp;nbsp; Most databases that&amp;nbsp; are&amp;nbsp; able&amp;nbsp; to&lt;br /&gt;
accomplish this are said to be&amp;nbsp; ACID­compliant.&amp;nbsp;&amp;nbsp; The ACID model is one of the&lt;br /&gt;
oldest and most important concepts of database theory.&amp;nbsp; The four goals that must&lt;br /&gt;
be&amp;nbsp;&amp;nbsp; met&amp;nbsp; for&amp;nbsp;&amp;nbsp; any&amp;nbsp;&amp;nbsp; database&amp;nbsp;&amp;nbsp; to&amp;nbsp;&amp;nbsp; be&amp;nbsp;&amp;nbsp; considered&amp;nbsp;&amp;nbsp; reliable&amp;nbsp;&amp;nbsp; are&amp;nbsp; Atomicity,&amp;nbsp; Consistency,&lt;br /&gt;
Isolation and&amp;nbsp; Durability (ACID).&amp;nbsp; Let’s examine each of these four characteristics&lt;br /&gt;
in detail.&lt;br /&gt;
Atomicity&amp;nbsp; means database modifications must follow an “all or nothing”&lt;br /&gt;
rule.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Every&amp;nbsp;&amp;nbsp; transaction&amp;nbsp;&amp;nbsp; is&amp;nbsp;&amp;nbsp; considered&amp;nbsp;&amp;nbsp; an&amp;nbsp;&amp;nbsp; “atomic”&amp;nbsp;&amp;nbsp; unit.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If&amp;nbsp;&amp;nbsp; any&amp;nbsp;&amp;nbsp; part&amp;nbsp;&amp;nbsp; of&amp;nbsp;&amp;nbsp; the&lt;br /&gt;
transaction fails, the entire transaction fails.&amp;nbsp; It is critical the DBMS maintain the&lt;br /&gt;
atomic nature of transactions in any circumstance. &lt;br /&gt;
331&lt;br /&gt;
&lt;h2&gt;A Beginner&#39;s Guide to Gambas&lt;/h2&gt;Consistency&amp;nbsp; states&amp;nbsp;&amp;nbsp; only&amp;nbsp;&amp;nbsp; valid&amp;nbsp;&amp;nbsp; data&amp;nbsp;&amp;nbsp; will&amp;nbsp;&amp;nbsp; be&amp;nbsp;&amp;nbsp; written&amp;nbsp;&amp;nbsp; to&amp;nbsp;&amp;nbsp; a&amp;nbsp;&amp;nbsp; database.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If&amp;nbsp;&amp;nbsp; a&lt;br /&gt;
transaction&amp;nbsp;&amp;nbsp; is&amp;nbsp;&amp;nbsp; executed&amp;nbsp;&amp;nbsp; that&amp;nbsp;&amp;nbsp; violates&amp;nbsp;&amp;nbsp; database&amp;nbsp;&amp;nbsp; consistency&amp;nbsp;&amp;nbsp; rules,&amp;nbsp;&amp;nbsp; the&amp;nbsp;&amp;nbsp; entire&lt;br /&gt;
transaction&amp;nbsp;&amp;nbsp; will&amp;nbsp;&amp;nbsp; be&amp;nbsp;&amp;nbsp; rolled&amp;nbsp;&amp;nbsp; back&amp;nbsp;&amp;nbsp; and&amp;nbsp;&amp;nbsp; the&amp;nbsp;&amp;nbsp; database&amp;nbsp;&amp;nbsp; will&amp;nbsp;&amp;nbsp; be&amp;nbsp;&amp;nbsp; restored&amp;nbsp;&amp;nbsp; to&amp;nbsp;&amp;nbsp; a&amp;nbsp;&amp;nbsp; state&lt;br /&gt;
consistent with those rules.&amp;nbsp;&amp;nbsp; Conversely, if a transaction executes successfully, it&lt;br /&gt;
will maintain a state of consistency. &lt;br /&gt;
Isolation&amp;nbsp; requires&amp;nbsp;&amp;nbsp; multiple&amp;nbsp;&amp;nbsp; transactions&amp;nbsp;&amp;nbsp; that&amp;nbsp;&amp;nbsp; occur&amp;nbsp;&amp;nbsp; simultaneously&amp;nbsp;&amp;nbsp; not&lt;br /&gt;
impact each other.&amp;nbsp; For example, if User A issues a transaction against a database&lt;br /&gt;
at the same time User B issues a transaction, both transactions should operate on&lt;br /&gt;
the&amp;nbsp;&amp;nbsp; database&amp;nbsp;&amp;nbsp; in&amp;nbsp;&amp;nbsp; isolated&amp;nbsp;&amp;nbsp; bliss.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The&amp;nbsp;&amp;nbsp; database&amp;nbsp;&amp;nbsp; should&amp;nbsp;&amp;nbsp; perform&amp;nbsp;&amp;nbsp; one&amp;nbsp;&amp;nbsp; transaction&lt;br /&gt;
before&amp;nbsp;&amp;nbsp; the&amp;nbsp;&amp;nbsp; other.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; This&amp;nbsp;&amp;nbsp; prevents&amp;nbsp;&amp;nbsp; a&amp;nbsp;&amp;nbsp; transaction&amp;nbsp;&amp;nbsp; from&amp;nbsp;&amp;nbsp; reading&amp;nbsp;&amp;nbsp; intermediate&amp;nbsp;&amp;nbsp; data&lt;br /&gt;
produced as a side effect of another transaction.&amp;nbsp; Isolation does not ensure either&lt;br /&gt;
transaction will execute first, just that they will not interfere with each other. &lt;br /&gt;
Durability ensures any transaction committed to the database will not be&lt;br /&gt;
lost.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; This&amp;nbsp;&amp;nbsp; is&amp;nbsp;&amp;nbsp; accomplished&amp;nbsp;&amp;nbsp; via&amp;nbsp;&amp;nbsp; database&amp;nbsp;&amp;nbsp; backups&amp;nbsp;&amp;nbsp; and&amp;nbsp;&amp;nbsp; transaction&amp;nbsp;&amp;nbsp; logs&amp;nbsp;&amp;nbsp; that&lt;br /&gt;
facilitate restoration of committed transactions despite any subsequent failures.&lt;br /&gt;
Now, let&#39;s take a look at Gambas Connection class methods available to you in&lt;br /&gt;
your programs.&lt;br /&gt;
Connection Class Methods&lt;br /&gt;
The&amp;nbsp; Connection&amp;nbsp;&amp;nbsp; class&amp;nbsp; provides&amp;nbsp;&amp;nbsp; most&amp;nbsp;&amp;nbsp; of&amp;nbsp;&amp;nbsp; the&amp;nbsp;&amp;nbsp; methods&amp;nbsp;&amp;nbsp; you&amp;nbsp;&amp;nbsp; will&amp;nbsp;&amp;nbsp; need&amp;nbsp;&amp;nbsp; to&lt;br /&gt;
establish a connection to a database and execute one or more transactions to find,&lt;br /&gt;
add, change, or delete data.&amp;nbsp; &lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
Open/Close&lt;br /&gt;
The Open method is used to open a connection to the database.&amp;nbsp; Prior to&lt;br /&gt;
making the call to Open, you should set the connection properties with the data&lt;br /&gt;
necessary to use the database.&amp;nbsp; Generally, at a minimum you will need to specify&lt;br /&gt;
the type of database, the host, a login ID and password, and&amp;nbsp; the name of the&lt;br /&gt;
database you wish to use.&amp;nbsp; The syntax for open is:&lt;br /&gt;
FUNCTION Open ( ) AS Boolean &lt;br /&gt;
The code example below shows how to use the Open method to connect&lt;br /&gt;
user&amp;nbsp; jrittinghouse&amp;nbsp; to a MySQL database named “GambasBugs” that is stored on&lt;br /&gt;
Host localhost:&lt;br /&gt;
DIM $hConn As NEW Connection&lt;br /&gt;
332&lt;br /&gt;
A Beginner&#39;s Guide to Gambas&lt;br /&gt;
WITH $hConn&lt;br /&gt;
&amp;nbsp;&amp;nbsp; .Type = &quot;mysql&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; .Host = &quot;localhost&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; .Login = &quot;jrittinghouse&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; .Password = &quot;ab32e44&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; .Name = &quot;GambasBugs&quot;&lt;br /&gt;
END WITH&lt;br /&gt;
TRY $hConn.Open&lt;br /&gt;
IF Error THEN PRINT &quot;Database cannot be opened. Error = &quot;; Error.Text&lt;br /&gt;
To close the connection, simply invoke the Close method.&amp;nbsp; In our example above,&lt;br /&gt;
you could use this code:&lt;br /&gt;
$hConn.Close&lt;br /&gt;
and the connection would be closed.&amp;nbsp; In order to subsequently use any data stored&lt;br /&gt;
in the database, you would need to re­open the database using the Open method.&lt;br /&gt;
Begin/Commit/Rollback&lt;br /&gt;
As we stated previously, a transaction is one or more individual database&lt;br /&gt;
queries&amp;nbsp;&amp;nbsp; that&amp;nbsp;&amp;nbsp; are&amp;nbsp;&amp;nbsp; grouped&amp;nbsp;&amp;nbsp; together&amp;nbsp;&amp;nbsp; between&amp;nbsp;&amp;nbsp; BEGIN&amp;nbsp;&amp;nbsp; and&amp;nbsp;&amp;nbsp; COMMIT&amp;nbsp;&amp;nbsp; statements.&lt;br /&gt;
Without&amp;nbsp;&amp;nbsp; a&amp;nbsp;&amp;nbsp; COMMIT&amp;nbsp;&amp;nbsp; statement,&amp;nbsp;&amp;nbsp; the&amp;nbsp;&amp;nbsp; transaction&amp;nbsp;&amp;nbsp; is&amp;nbsp;&amp;nbsp; not&amp;nbsp;&amp;nbsp; permanent&amp;nbsp;&amp;nbsp; and&amp;nbsp;&amp;nbsp; can&amp;nbsp;&amp;nbsp; be&lt;br /&gt;
reversed&amp;nbsp;&amp;nbsp; with&amp;nbsp; a&amp;nbsp; ROLLBACK&amp;nbsp; statement.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Remember&amp;nbsp;&amp;nbsp; that MySQL&amp;nbsp;&amp;nbsp; automatically&lt;br /&gt;
commits statements that are not part of a transaction process (defined by BEGIN&lt;br /&gt;
and COMMIT).&amp;nbsp; In Gambas, it is recommended that you use the Find, Create, and&lt;br /&gt;
Edit&amp;nbsp;&amp;nbsp; methods&amp;nbsp;&amp;nbsp; to&amp;nbsp;&amp;nbsp; make&amp;nbsp;&amp;nbsp; changes&amp;nbsp;&amp;nbsp; to&amp;nbsp;&amp;nbsp; the&amp;nbsp;&amp;nbsp; database.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; This&amp;nbsp;&amp;nbsp; helps&amp;nbsp; to&amp;nbsp;&amp;nbsp; maintain&amp;nbsp;&amp;nbsp; code&lt;br /&gt;
independence and it allows you to write a single piece of code that will work with&lt;br /&gt;
any database supported by Gambas.&amp;nbsp;&amp;nbsp; Gambas uses a&amp;nbsp; result object&amp;nbsp; to return the&lt;br /&gt;
results of a SQL query.&amp;nbsp; &lt;br /&gt;
Find&lt;br /&gt;
The&amp;nbsp;&amp;nbsp; Find&amp;nbsp;&amp;nbsp; method&amp;nbsp;&amp;nbsp; returns&amp;nbsp;&amp;nbsp; a&amp;nbsp;&amp;nbsp; read­only&amp;nbsp; Result&amp;nbsp;&amp;nbsp; object&amp;nbsp; used&amp;nbsp;&amp;nbsp; for&amp;nbsp;&amp;nbsp; querying&lt;br /&gt;
records in the specified table.&amp;nbsp; The calling convention for Find is:&lt;br /&gt;
FUNCTION Find (Table AS String [, Request AS String, Arguments AS , ... ] ) AS Result &lt;br /&gt;
Request&amp;nbsp; represents a&amp;nbsp; SQL WHERE statement&amp;nbsp; that is used for querying the&lt;br /&gt;
table.&amp;nbsp;&amp;nbsp;&amp;nbsp; Arguments&amp;nbsp; are&amp;nbsp;&amp;nbsp; quoted&amp;nbsp;&amp;nbsp; as&amp;nbsp;&amp;nbsp; necessary&amp;nbsp;&amp;nbsp; (dictated&amp;nbsp;&amp;nbsp; by&amp;nbsp;&amp;nbsp; SQL&amp;nbsp;&amp;nbsp; syntax),&amp;nbsp;&amp;nbsp; and&lt;br /&gt;
substituted inside the Request string.&amp;nbsp;&amp;nbsp; It works like the Subst() function in this&lt;br /&gt;
333&lt;br /&gt;
&lt;h2&gt;A Beginner&#39;s Guide to Gambas&lt;/h2&gt;case.&amp;nbsp; Using the Find method allows you to write requests that are independent of&lt;br /&gt;
the underlying database, meaning it will work with PostgreSQL or MySQL without&lt;br /&gt;
any code change required.&lt;br /&gt;
Create&lt;br /&gt;
The Create method is used to build a read/write Result object which can&lt;br /&gt;
used to create records in a table.&amp;nbsp; Standard calling convention is:&lt;br /&gt;
FUNCTION Create ( Table AS String ) AS Result &lt;br /&gt;
Edit&lt;br /&gt;
The Edit method returns a read/write Result object used for editing records&lt;br /&gt;
in the specified table.&amp;nbsp;&amp;nbsp; Query&amp;nbsp; is equivalent to an embedded SQL WHERE clause&lt;br /&gt;
used for filtering the table, and the Arguments are quoted as needed by the SQL&lt;br /&gt;
syntax and substituted in the Request string (like in sscanf in C) as we explained&lt;br /&gt;
previously.&amp;nbsp; Standard calling convention is: &lt;br /&gt;
FUNCTION Edit ( Table AS String [ , Query AS String, Arguments AS , ... ] ) AS Result&lt;br /&gt;
Here is a code sample to show how Edit() works:&lt;br /&gt;
DIM MyResult AS Result&lt;br /&gt;
DIM sQuery AS String&lt;br /&gt;
DIM iParm AS Integer&lt;br /&gt;
sQuery = &quot;id=&amp;amp;1&quot; &lt;br /&gt;
&#39; we will insert a parameter value (12) at the end of the query string&lt;br /&gt;
iParm = 12&lt;br /&gt;
$hConn.Begin&lt;br /&gt;
MyResult=$hConn.Edit(&quot;tblDEFAULT&quot;, sQuery, iParm)&lt;br /&gt;
MyResult!Name = &quot;Mr Rittinghouse&quot; &#39; Set a field value&lt;br /&gt;
$hConn.Update &#39; Update with the new value&lt;br /&gt;
$hConn.Commit &#39; make the changes permanent&lt;br /&gt;
$hConn.Close&amp;nbsp; &#39; close the database connection&lt;br /&gt;
Exec&lt;br /&gt;
The Exec method executes a SQL request and returns a read­only Result&lt;br /&gt;
object containing the result of the request.&amp;nbsp; Standard calling convention is:&lt;br /&gt;
FUNCTION Exec ( Request AS String, Arguments AS , ... ) AS Result</content><link rel='replies' type='application/atom+xml' href='http://gambas-data-grid-codes-database.blogspot.com/feeds/6194009271311429821/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gambas-data-grid-codes-database.blogspot.com/2012/04/gambas-mysql.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7940058950332398351/posts/default/6194009271311429821'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7940058950332398351/posts/default/6194009271311429821'/><link rel='alternate' type='text/html' href='http://gambas-data-grid-codes-database.blogspot.com/2012/04/gambas-mysql.html' title='Gambas mysql'/><author><name>Allsearchengines.blogspot.com</name><uri>http://www.blogger.com/profile/11174269673917299671</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDdRnmNEk1Cp57AEcyvDr0xIJUe31vfRyGDqSRrBTu4iWfHkMJOy6wDjAkD4kbsGlkUggE6ftsFne7EGiSX-0a2VqNGHX0VQbPkVeENtRbworeumQhmIVi4S9fjgifgLs/s220/25299_1188449160606_1509634281_30384185_4723363_a.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7940058950332398351.post-505612908558017184</id><published>2012-03-29T10:41:00.002-07:00</published><updated>2012-03-29T10:41:37.771-07:00</updated><title type='text'>Gambas DB connection</title><content type='html'>A Beginner&#39;s Guide to Gambas&lt;br /&gt;
property is null, a database is opened in memory.&amp;nbsp;&amp;nbsp; If the Name specified is an&lt;br /&gt;
absolute path, the pathname is used.&amp;nbsp; If the Name specified is a relative path and&lt;br /&gt;
the Host property is null, the database is located&amp;nbsp; in the application temporary&lt;br /&gt;
directory&amp;nbsp; /tmp/gambas.$UID/sqlite.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Otherwise,&amp;nbsp;&amp;nbsp; Host&amp;nbsp;&amp;nbsp; will&amp;nbsp;&amp;nbsp; contain&amp;nbsp;&amp;nbsp; the&amp;nbsp;&amp;nbsp; database&lt;br /&gt;
directory name and the database file path is the result of concatenating the Host&lt;br /&gt;
and Name property values.&amp;nbsp; This class is creatable and the calling convention is:&lt;br /&gt;
DIM hConnection AS Connection&lt;br /&gt;
hConnection = NEW Connection() &lt;br /&gt;
Connection Properties&lt;br /&gt;
When&amp;nbsp;&amp;nbsp; the&amp;nbsp; hConnection&amp;nbsp; object&amp;nbsp;&amp;nbsp; is&amp;nbsp;&amp;nbsp; instantiated,&amp;nbsp;&amp;nbsp; it&amp;nbsp;&amp;nbsp; creates&amp;nbsp;&amp;nbsp; a&amp;nbsp;&amp;nbsp; new&amp;nbsp;&amp;nbsp; void&lt;br /&gt;
connection&amp;nbsp;&amp;nbsp; object.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; You&amp;nbsp;&amp;nbsp; will&amp;nbsp;&amp;nbsp; then&amp;nbsp;&amp;nbsp; need&amp;nbsp;&amp;nbsp; to&amp;nbsp;&amp;nbsp; set&amp;nbsp;&amp;nbsp; properties&amp;nbsp;&amp;nbsp; for&amp;nbsp;&amp;nbsp; this&amp;nbsp;&amp;nbsp; object.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The&lt;br /&gt;
properties that you can use with a connection object include Charset, Databases,&lt;br /&gt;
Host, Login, Password, Name, Port, Tables, Type, Users and&amp;nbsp; Version.&amp;nbsp;&amp;nbsp; We will&lt;br /&gt;
explain each of these in the following sections.&lt;br /&gt;
Charset&lt;br /&gt;
Charset&amp;nbsp;&amp;nbsp; is&amp;nbsp;&amp;nbsp; a&amp;nbsp;&amp;nbsp; read­only&amp;nbsp;&amp;nbsp; property&amp;nbsp;&amp;nbsp; that&amp;nbsp;&amp;nbsp; returns&amp;nbsp;&amp;nbsp; the&amp;nbsp;&amp;nbsp; charset&amp;nbsp;&amp;nbsp; used&amp;nbsp;&amp;nbsp; by&amp;nbsp;&amp;nbsp; the&lt;br /&gt;
database.&amp;nbsp;&amp;nbsp; It is possible for you to store your strings in the database directly in&lt;br /&gt;
UTF­8 format.&amp;nbsp;&amp;nbsp; However, you can also can use this property combined with the&lt;br /&gt;
Conv$() subroutine to convert from UTF­8 format to the database charset format.&lt;br /&gt;
Using&amp;nbsp;&amp;nbsp; the&amp;nbsp;&amp;nbsp; database&amp;nbsp;&amp;nbsp; charset&amp;nbsp;&amp;nbsp; comes&amp;nbsp;&amp;nbsp; at&amp;nbsp;&amp;nbsp; a&amp;nbsp;&amp;nbsp; cost&amp;nbsp;&amp;nbsp; in&amp;nbsp;&amp;nbsp; performance&amp;nbsp;&amp;nbsp; however.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; This&amp;nbsp;&amp;nbsp; is&lt;br /&gt;
because you must use the Conv$() subroutine each and every time you read or&lt;br /&gt;
write string data to the database fields.&amp;nbsp; For now, this is the only way you can do&lt;br /&gt;
this if you want to use the string­based SQL functions and built­in sort routines of&lt;br /&gt;
the underlying&amp;nbsp; database management system (MySQL, PostgreSQL, or SQLite).&lt;br /&gt;
Future&amp;nbsp;&amp;nbsp; versions&amp;nbsp;&amp;nbsp; of&amp;nbsp;&amp;nbsp; Gambas&amp;nbsp; may&amp;nbsp; automatically&amp;nbsp;&amp;nbsp; make&amp;nbsp;&amp;nbsp; the&amp;nbsp;&amp;nbsp; conversion&amp;nbsp;&amp;nbsp; between&lt;br /&gt;
Gambas strings and the database charset.&lt;br /&gt;
Databases&lt;br /&gt;
The&amp;nbsp; Databases property&amp;nbsp; can be checked to obtain a collection object that&lt;br /&gt;
will&amp;nbsp;&amp;nbsp; contain&amp;nbsp; names&amp;nbsp; of&amp;nbsp; all&amp;nbsp;&amp;nbsp; databases&amp;nbsp;&amp;nbsp; that&amp;nbsp; are&amp;nbsp;&amp;nbsp; managed&amp;nbsp;&amp;nbsp; by&amp;nbsp;&amp;nbsp; the&amp;nbsp;&amp;nbsp; database&amp;nbsp;&amp;nbsp; server.&lt;br /&gt;
Syntax is:&lt;br /&gt;
PROPERTY Databases AS .ConnectionDatabases &lt;br /&gt;
The&amp;nbsp;&amp;nbsp; resulting&amp;nbsp;&amp;nbsp; collection&amp;nbsp;&amp;nbsp; of&amp;nbsp;&amp;nbsp; data&amp;nbsp;&amp;nbsp; (which&amp;nbsp;&amp;nbsp; is&amp;nbsp;&amp;nbsp; enumerable&amp;nbsp;&amp;nbsp; using&amp;nbsp;&amp;nbsp; the&amp;nbsp;&amp;nbsp; FOR&amp;nbsp;&amp;nbsp; EACH&lt;br /&gt;
328&lt;br /&gt;
A Beginner&#39;s Guide to Gambas&lt;br /&gt;
statement) would be the same as if you typed SHOW DATABASES from the mysql&lt;br /&gt;
client CLI.&lt;br /&gt;
&lt;br /&gt;
Host&lt;br /&gt;
You can use the&amp;nbsp; Host property&amp;nbsp; to set or get the host name of where the&lt;br /&gt;
database server is located.&amp;nbsp; The host name can be either a machine name or an IP&lt;br /&gt;
address.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The&amp;nbsp;&amp;nbsp; default&amp;nbsp;&amp;nbsp; host&amp;nbsp;&amp;nbsp; is&amp;nbsp;&amp;nbsp; named&amp;nbsp;&amp;nbsp; localhost.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; In&amp;nbsp;&amp;nbsp; SQLite,&amp;nbsp;&amp;nbsp; host&amp;nbsp;&amp;nbsp; name&amp;nbsp;&amp;nbsp; is&amp;nbsp;&amp;nbsp; not&lt;br /&gt;
relevant&amp;nbsp;&amp;nbsp; since&amp;nbsp;&amp;nbsp; SQLite&amp;nbsp;&amp;nbsp; is&amp;nbsp;&amp;nbsp; not&amp;nbsp;&amp;nbsp; a&amp;nbsp;&amp;nbsp; client/server&amp;nbsp;&amp;nbsp; database&amp;nbsp;&amp;nbsp; sytstem.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; However,&amp;nbsp;&amp;nbsp; from&lt;br /&gt;
version 0.95 forward, it is possible for you to set the home path for the SQLite&lt;br /&gt;
database by using this property.&amp;nbsp; Syntax for using the Host property is:&lt;br /&gt;
PROPERTY Host AS String &lt;br /&gt;
Login&lt;br /&gt;
The Login property is used to set or get the user login data that is used for&lt;br /&gt;
establishing the connection to the database.&amp;nbsp;&amp;nbsp; Once again, this applies to MySQL&lt;br /&gt;
and PostgreSQL, not SQLite.&amp;nbsp;&amp;nbsp; Since SQLite has no concept of users, access to a&lt;br /&gt;
SQLite database is controlled by the file permission settings of the database file&lt;br /&gt;
itself.&amp;nbsp; This means that the Login property is always going to be set to the user id&lt;br /&gt;
of the user that is executing the Gambas program that uses the SQLite database.&lt;br /&gt;
Syntax is:&lt;br /&gt;
PROPERTY Login AS String &lt;br /&gt;
Name&lt;br /&gt;
The&amp;nbsp; Name&amp;nbsp; property&amp;nbsp; sets or&amp;nbsp;&amp;nbsp; gets&amp;nbsp; the&amp;nbsp; name&amp;nbsp;&amp;nbsp; of&amp;nbsp;&amp;nbsp; the&amp;nbsp;&amp;nbsp; database&amp;nbsp;&amp;nbsp; you&amp;nbsp;&amp;nbsp; want&amp;nbsp;&amp;nbsp; to&lt;br /&gt;
connect to.&amp;nbsp; If you do not specify a name, a default system database is used.&amp;nbsp; For&lt;br /&gt;
PostgreSQL the default database is named&amp;nbsp; template1 and for mySQL it is named&lt;br /&gt;
mysql.&amp;nbsp; For SQLite, the default name is /tmp/sqlite.db.&amp;nbsp; For any database access,&lt;br /&gt;
however, the user needs to have at least read and connect access privileges to use&lt;br /&gt;
these&amp;nbsp; databases.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Sqlite&amp;nbsp;&amp;nbsp; will&amp;nbsp;&amp;nbsp; locate&amp;nbsp; the&amp;nbsp;&amp;nbsp; database&amp;nbsp; first&amp;nbsp; by&amp;nbsp; trying&amp;nbsp;&amp;nbsp; to&amp;nbsp; use&amp;nbsp;&amp;nbsp; the&amp;nbsp; full&lt;br /&gt;
pathname if it has been given.&amp;nbsp; If not, it will check to see if the Host variable has&lt;br /&gt;
been set.&amp;nbsp; If that is the case, SQLite will look at the path name that was set in the&lt;br /&gt;
variable.&amp;nbsp; If the environment variable GAMBAS_SQLITE_DBHOME has been set,&lt;br /&gt;
then SQLite will use that as the current working directory.&amp;nbsp; It is also possible to&lt;br /&gt;
create&amp;nbsp;&amp;nbsp; and&amp;nbsp;&amp;nbsp; use&amp;nbsp;&amp;nbsp; a&amp;nbsp;&amp;nbsp; database&amp;nbsp;&amp;nbsp; in&amp;nbsp;&amp;nbsp; memory&amp;nbsp;&amp;nbsp; by&amp;nbsp;&amp;nbsp; setting&amp;nbsp;&amp;nbsp; the&amp;nbsp;&amp;nbsp; Name&amp;nbsp;&amp;nbsp; property&amp;nbsp;&amp;nbsp; to&lt;br /&gt;
“:memory:” rather than “mysql” or “postgresql” or “sqlite”.&amp;nbsp; Syntax is:&lt;br /&gt;
329&lt;br /&gt;
A Beginner&#39;s Guide to Gambas&lt;br /&gt;
PROPERTY Name AS String &lt;br /&gt;
Password&lt;br /&gt;
The Password property will return or set the password used for establishing&lt;br /&gt;
a connection to the database.&amp;nbsp; Calling convention is:&lt;br /&gt;
PROPERTY Password AS String &lt;br /&gt;
Port&lt;br /&gt;
The Port property is used to get or set the TCP/IP port used for establishing&lt;br /&gt;
the connection to a database.&amp;nbsp; The default port depends on the connection Type.&lt;br /&gt;
Syntax is:&lt;br /&gt;
PROPERTY Port AS String &lt;br /&gt;
Tables&lt;br /&gt;
The Tables property is used to obtain a virtual collection that can be used&lt;br /&gt;
for managing all of the tables of a database.&amp;nbsp; Syntax is:&lt;br /&gt;
PROPERTY Tables AS .ConnectionTables &lt;br /&gt;
Type&lt;br /&gt;
The Type property represents the type of the database server you want to&lt;br /&gt;
connect to.&amp;nbsp;&amp;nbsp; In Gambas, the currently supported databasetype are: &quot;postgresql&quot;,&lt;br /&gt;
&quot;mysql&quot;, and &quot;sqlite&quot;.&amp;nbsp; The type property uses this syntax:&lt;br /&gt;
PROPERTY Type AS String &lt;br /&gt;
Users&lt;br /&gt;
The&amp;nbsp; Users&amp;nbsp;&amp;nbsp; property&amp;nbsp; returns&amp;nbsp;&amp;nbsp; a&amp;nbsp;&amp;nbsp; collection&amp;nbsp;&amp;nbsp; of&amp;nbsp;&amp;nbsp; all&amp;nbsp;&amp;nbsp; users&amp;nbsp;&amp;nbsp; registered&amp;nbsp;&amp;nbsp; in&amp;nbsp;&amp;nbsp; the&lt;br /&gt;
database server.&amp;nbsp; Like any other collection object, it can be enumerated with FOR&lt;br /&gt;
EACH.&amp;nbsp; Syntax is:&lt;br /&gt;
PROPERTY Users AS .ConnectionUsers &lt;br /&gt;
Version&lt;br /&gt;
&lt;br /&gt;
The&amp;nbsp; Version property&amp;nbsp; is a read­only value that returns the version of the&lt;br /&gt;
330&lt;br /&gt;
A Beginner&#39;s Guide to Gambas&lt;br /&gt;
database that the driver has connected with.&amp;nbsp; Syntax is:&lt;br /&gt;
PROPERTY READ Version AS Integer &lt;br /&gt;
The Concept of a Transaction&lt;br /&gt;
There are times when the order in which database actions (or queries) are&lt;br /&gt;
executed is important.&amp;nbsp; Sometimes, a program must ensure all queries in a group&lt;br /&gt;
are run successfully and in order or process none of them at all.&amp;nbsp; A classic example&lt;br /&gt;
is&amp;nbsp;&amp;nbsp; taken&amp;nbsp;&amp;nbsp; from&amp;nbsp;&amp;nbsp; the&amp;nbsp;&amp;nbsp; banking&amp;nbsp;&amp;nbsp; environment.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If&amp;nbsp;&amp;nbsp; a&amp;nbsp;&amp;nbsp; given&amp;nbsp;&amp;nbsp; amount&amp;nbsp;&amp;nbsp; of&amp;nbsp;&amp;nbsp; money&amp;nbsp;&amp;nbsp; (for&lt;br /&gt;
example, 100 dollars) is taken from one account and posted to another account,&lt;br /&gt;
we would expect the following actions to occur:&lt;br /&gt;
UPDATE account1 SET balance = balance ­ 100;&lt;br /&gt;
UPDATE account2 SET balance = balance + 100;&lt;br /&gt;
Both queries must execute successfully or neither must execute.&amp;nbsp;&amp;nbsp; Money&lt;br /&gt;
cannot&amp;nbsp;&amp;nbsp; be&amp;nbsp;&amp;nbsp; transferred&amp;nbsp;&amp;nbsp; out&amp;nbsp;&amp;nbsp; of&amp;nbsp;&amp;nbsp; one&amp;nbsp;&amp;nbsp; account&amp;nbsp;&amp;nbsp; and&amp;nbsp;&amp;nbsp; fail&amp;nbsp;&amp;nbsp; to&amp;nbsp;&amp;nbsp; be&amp;nbsp;&amp;nbsp; posted&amp;nbsp;&amp;nbsp; to&amp;nbsp;&amp;nbsp; the&amp;nbsp;&amp;nbsp; other&lt;br /&gt;
account.&amp;nbsp; Both of these queries form a single transaction that is composed of two&lt;br /&gt;
separate&amp;nbsp;&amp;nbsp; actions&amp;nbsp;&amp;nbsp; (debit&amp;nbsp;&amp;nbsp; 100&amp;nbsp;&amp;nbsp; from&amp;nbsp;&amp;nbsp; account1&amp;nbsp;&amp;nbsp; and&amp;nbsp;&amp;nbsp; credit&amp;nbsp;&amp;nbsp; 100&amp;nbsp;&amp;nbsp; to&amp;nbsp;&amp;nbsp; account2).&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A&lt;br /&gt;
transaction&amp;nbsp; is simply one or more individual database queries grouped together&lt;br /&gt;
between&amp;nbsp; BEGIN&amp;nbsp; and&amp;nbsp; COMMIT&amp;nbsp; statements.&amp;nbsp;&amp;nbsp; Without a COMMIT statement, the&lt;br /&gt;
transaction is not permanent and can be reversed with the ROLLBACK statement.&lt;br /&gt;
MySQL automatically commits statements that are not part of a transaction&lt;br /&gt;
process.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The&amp;nbsp;&amp;nbsp; results&amp;nbsp;&amp;nbsp; of&amp;nbsp;&amp;nbsp; any&amp;nbsp;&amp;nbsp; SQL&amp;nbsp;&amp;nbsp; UPDATE&amp;nbsp;&amp;nbsp; or&amp;nbsp;&amp;nbsp; INSERT&amp;nbsp;&amp;nbsp; statement&amp;nbsp;&amp;nbsp; that&amp;nbsp;&amp;nbsp; is&amp;nbsp;&amp;nbsp; not&lt;br /&gt;
preceded&amp;nbsp;&amp;nbsp; with&amp;nbsp;&amp;nbsp; BEGIN&amp;nbsp;&amp;nbsp; will&amp;nbsp;&amp;nbsp; immediately&amp;nbsp;&amp;nbsp; be&amp;nbsp;&amp;nbsp; visible&amp;nbsp;&amp;nbsp; to&amp;nbsp;&amp;nbsp; all&amp;nbsp;&amp;nbsp; connections&amp;nbsp;&amp;nbsp; to&amp;nbsp;&amp;nbsp; the&lt;br /&gt;
database&amp;nbsp;&amp;nbsp; because&amp;nbsp;&amp;nbsp; the&amp;nbsp;&amp;nbsp; commit&amp;nbsp;&amp;nbsp; is&amp;nbsp;&amp;nbsp; automatically&amp;nbsp;&amp;nbsp; performed.&amp;nbsp;&amp;nbsp;&amp;nbsp; Within&amp;nbsp;&amp;nbsp; MySQL,&lt;br /&gt;
transactions are only known with “transaction safe” tables (i.e., BDB and InnoDB).&lt;br /&gt;
The&amp;nbsp; other&amp;nbsp; table&amp;nbsp; types&amp;nbsp; COMMIT&amp;nbsp;&amp;nbsp; immediately.&amp;nbsp;&amp;nbsp; Most databases that&amp;nbsp; are&amp;nbsp; able&amp;nbsp; to&lt;br /&gt;
accomplish this are said to be&amp;nbsp; ACID­compliant.&amp;nbsp;&amp;nbsp; The ACID model is one of the&lt;br /&gt;
oldest and most important concepts of database theory.&amp;nbsp; The four goals that must&lt;br /&gt;
be&amp;nbsp;&amp;nbsp; met&amp;nbsp; for&amp;nbsp;&amp;nbsp; any&amp;nbsp;&amp;nbsp; database&amp;nbsp;&amp;nbsp; to&amp;nbsp;&amp;nbsp; be&amp;nbsp;&amp;nbsp; considered&amp;nbsp;&amp;nbsp; reliable&amp;nbsp;&amp;nbsp; are&amp;nbsp; Atomicity,&amp;nbsp; Consistency,&lt;br /&gt;
Isolation and&amp;nbsp; Durability (ACID).&amp;nbsp; Let’s examine each of these four characteristics&lt;br /&gt;
in detail.&lt;br /&gt;
Atomicity&amp;nbsp; means database modifications must follow an “all or nothing”&lt;br /&gt;
rule.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Every&amp;nbsp;&amp;nbsp; transaction&amp;nbsp;&amp;nbsp; is&amp;nbsp;&amp;nbsp; considered&amp;nbsp;&amp;nbsp; an&amp;nbsp;&amp;nbsp; “atomic”&amp;nbsp;&amp;nbsp; unit.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If&amp;nbsp;&amp;nbsp; any&amp;nbsp;&amp;nbsp; part&amp;nbsp;&amp;nbsp; of&amp;nbsp;&amp;nbsp; the&lt;br /&gt;
transaction fails, the entire transaction fails.&amp;nbsp; It is critical the DBMS maintain the&lt;br /&gt;
atomic nature of transactions in any circumstance. &lt;br /&gt;
331&lt;br /&gt;
A Beginner&#39;s Guide to Gambas&lt;br /&gt;
Consistency&amp;nbsp; states&amp;nbsp;&amp;nbsp; only&amp;nbsp;&amp;nbsp; valid&amp;nbsp;&amp;nbsp; data&amp;nbsp;&amp;nbsp; will&amp;nbsp;&amp;nbsp; be&amp;nbsp;&amp;nbsp; written&amp;nbsp;&amp;nbsp; to&amp;nbsp;&amp;nbsp; a&amp;nbsp;&amp;nbsp; database.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If&amp;nbsp;&amp;nbsp; a&lt;br /&gt;
transaction&amp;nbsp;&amp;nbsp; is&amp;nbsp;&amp;nbsp; executed&amp;nbsp;&amp;nbsp; that&amp;nbsp;&amp;nbsp; violates&amp;nbsp;&amp;nbsp; database&amp;nbsp;&amp;nbsp; consistency&amp;nbsp;&amp;nbsp; rules,&amp;nbsp;&amp;nbsp; the&amp;nbsp;&amp;nbsp; entire&lt;br /&gt;
transaction&amp;nbsp;&amp;nbsp; will&amp;nbsp;&amp;nbsp; be&amp;nbsp;&amp;nbsp; rolled&amp;nbsp;&amp;nbsp; back&amp;nbsp;&amp;nbsp; and&amp;nbsp;&amp;nbsp; the&amp;nbsp;&amp;nbsp; database&amp;nbsp;&amp;nbsp; will&amp;nbsp;&amp;nbsp; be&amp;nbsp;&amp;nbsp; restored&amp;nbsp;&amp;nbsp; to&amp;nbsp;&amp;nbsp; a&amp;nbsp;&amp;nbsp; state&lt;br /&gt;
consistent with those rules.&amp;nbsp;&amp;nbsp; Conversely, if a transaction executes successfully, it&lt;br /&gt;
will maintain a state of consistency. &lt;br /&gt;
Isolation&amp;nbsp; requires&amp;nbsp;&amp;nbsp; multiple&amp;nbsp;&amp;nbsp; transactions&amp;nbsp;&amp;nbsp; that&amp;nbsp;&amp;nbsp; occur&amp;nbsp;&amp;nbsp; simultaneously&amp;nbsp;&amp;nbsp; not&lt;br /&gt;
impact each other.&amp;nbsp; For example, if User A issues a transaction against a database&lt;br /&gt;
at the same time User B issues a transaction, both transactions should operate on&lt;br /&gt;
the&amp;nbsp;&amp;nbsp; database&amp;nbsp;&amp;nbsp; in&amp;nbsp;&amp;nbsp; isolated&amp;nbsp;&amp;nbsp; bliss.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The&amp;nbsp;&amp;nbsp; database&amp;nbsp;&amp;nbsp; should&amp;nbsp;&amp;nbsp; perform&amp;nbsp;&amp;nbsp; one&amp;nbsp;&amp;nbsp; transaction&lt;br /&gt;
before&amp;nbsp;&amp;nbsp; the&amp;nbsp;&amp;nbsp; other.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; This&amp;nbsp;&amp;nbsp; prevents&amp;nbsp;&amp;nbsp; a&amp;nbsp;&amp;nbsp; transaction&amp;nbsp;&amp;nbsp; from&amp;nbsp;&amp;nbsp; reading&amp;nbsp;&amp;nbsp; intermediate&amp;nbsp;&amp;nbsp; data&lt;br /&gt;
produced as a side effect of another transaction.&amp;nbsp; Isolation does not ensure either&lt;br /&gt;
transaction will execute first, just that they will not interfere with each other. &lt;br /&gt;
Durability ensures any transaction committed to the database will not be&lt;br /&gt;
lost.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; This&amp;nbsp;&amp;nbsp; is&amp;nbsp;&amp;nbsp; accomplished&amp;nbsp;&amp;nbsp; via&amp;nbsp;&amp;nbsp; database&amp;nbsp;&amp;nbsp; backups&amp;nbsp;&amp;nbsp; and&amp;nbsp;&amp;nbsp; transaction&amp;nbsp;&amp;nbsp; logs&amp;nbsp;&amp;nbsp; that&lt;br /&gt;
facilitate restoration of committed transactions despite any subsequent failures.&lt;br /&gt;
Now, let&#39;s take a look at Gambas Connection class methods available to you in&lt;br /&gt;
your programs.&lt;br /&gt;
Connection Class Methods&lt;br /&gt;
The&amp;nbsp; Connection&amp;nbsp;&amp;nbsp; class&amp;nbsp; provides&amp;nbsp;&amp;nbsp; most&amp;nbsp;&amp;nbsp; of&amp;nbsp;&amp;nbsp; the&amp;nbsp;&amp;nbsp; methods&amp;nbsp;&amp;nbsp; you&amp;nbsp;&amp;nbsp; will&amp;nbsp;&amp;nbsp; need&amp;nbsp;&amp;nbsp; to&lt;br /&gt;
establish a connection to a database and execute one or more transactions to find,&lt;br /&gt;
add, change, or delete data.&amp;nbsp; &lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
Open/Close&lt;br /&gt;
The Open method is used to open a connection to the database.&amp;nbsp; Prior to&lt;br /&gt;
making the call to Open, you should set the connection properties with the data&lt;br /&gt;
necessary to use the database.&amp;nbsp; Generally, at a minimum you will need to specify&lt;br /&gt;
the type of database, the host, a login ID and password, and&amp;nbsp; the name of the&lt;br /&gt;
database you wish to use.&amp;nbsp; The syntax for open is:&lt;br /&gt;
FUNCTION Open ( ) AS Boolean &lt;br /&gt;
The code example below shows how to use the Open method to connect&lt;br /&gt;
user&amp;nbsp; jrittinghouse&amp;nbsp; to a MySQL database named “GambasBugs” that is stored on&lt;br /&gt;
Host localhost:&lt;br /&gt;
DIM $hConn As NEW Connection</content><link rel='replies' type='application/atom+xml' href='http://gambas-data-grid-codes-database.blogspot.com/feeds/505612908558017184/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gambas-data-grid-codes-database.blogspot.com/2012/03/gambas-db-connection.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7940058950332398351/posts/default/505612908558017184'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7940058950332398351/posts/default/505612908558017184'/><link rel='alternate' type='text/html' href='http://gambas-data-grid-codes-database.blogspot.com/2012/03/gambas-db-connection.html' title='Gambas DB connection'/><author><name>Allsearchengines.blogspot.com</name><uri>http://www.blogger.com/profile/11174269673917299671</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDdRnmNEk1Cp57AEcyvDr0xIJUe31vfRyGDqSRrBTu4iWfHkMJOy6wDjAkD4kbsGlkUggE6ftsFne7EGiSX-0a2VqNGHX0VQbPkVeENtRbworeumQhmIVi4S9fjgifgLs/s220/25299_1188449160606_1509634281_30384185_4723363_a.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7940058950332398351.post-7168150813700718656</id><published>2012-02-24T02:49:00.001-08:00</published><updated>2012-02-24T02:50:33.052-08:00</updated><title type='text'>Gridview1 or gambas data grid</title><content type='html'>&lt;h1&gt;Gridview and the Data Handling in gambas&amp;nbsp;Event&lt;/h1&gt;&lt;div class=&quot;entry&quot;&gt;Here is another short tutorial based around database work under  Gambas. I think Gambas is a marvelous data manipulation tool. I suspect  it has greater facility than the so-called 4th Generation ‘application  generators’ I was using not so long ago.&lt;br /&gt;
The tutorial highlights a feature of gridview display which saves  huge amounts of time when displaying large databases. The feature is  actually used in the Gambas database example so is nothing original. I  do find with a lot of Gambas examples that the the example author tries  too hard to show too many capabilities with the result that the example  itself becomes confusing.&lt;br /&gt;
The following Gambas2 code:&lt;br /&gt;
1 Deletes a file test.sqlite in the users home directory (if it exists).&lt;br /&gt;
2 Creates an SQLite database test.sqlite and defines a table sampleTable  with two integer fields, one a sequence (yes, I know SQLite does that  internally anyway!) and the other a random number.&lt;br /&gt;
3 Fills the table with 10000 records.&lt;br /&gt;
4 Displays the results in a gridview.&lt;br /&gt;
On Gambas you need nothing more than a gridview (gridview1) on an  otherwise empty form. The only interesting bit that may need explanation  is the GridView1_Data event. This is called to fill an empty gridview  cell as it is exposed (by scrolling). It saves having to load all 10000  records into the gridview with the time penalty that would imply.&lt;br /&gt;
Here is the code for FMain.class:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;syntaxhighlighter  plain&quot; id=&quot;highlighter_715787&quot;&gt;&lt;div class=&quot;bar                                                                                               &quot;&gt;&lt;div class=&quot;toolbar&quot;&gt;&lt;a class=&quot;item viewSource&quot; href=&quot;http://kalaharix.wordpress.com/gambas/gridview-and-the-data-handling-event/#viewSource&quot; style=&quot;height: 16px; width: 16px;&quot; title=&quot;view source&quot;&gt;view source&lt;/a&gt;&lt;a class=&quot;item printSource&quot; href=&quot;http://kalaharix.wordpress.com/gambas/gridview-and-the-data-handling-event/#printSource&quot; style=&quot;height: 16px; width: 16px;&quot; title=&quot;print&quot;&gt;print&lt;/a&gt;&lt;a class=&quot;item about&quot; href=&quot;http://kalaharix.wordpress.com/gambas/gridview-and-the-data-handling-event/#about&quot; style=&quot;height: 16px; width: 16px;&quot; title=&quot;?&quot;&gt;?&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;lines&quot;&gt;&lt;div class=&quot;line alt1&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;01&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;&#39; Gambas class file&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt2&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;02&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;PRIVATE $hConn AS NEW Connection&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt1&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;03&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;PRIVATE $res AS Result&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt2&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;04&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;&#39;-------------------------------------------------&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt1&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;05&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;PUBLIC SUB Form_Open()&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt2&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;06&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;DIM iCount AS Integer&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt1&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;07&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;DIM hTable AS Table&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt2&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;08&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;DIM rTest AS result&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt1&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;09&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;DIM sql AS String&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt2&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;10&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt1&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;11&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;&#39;define the gridview layout&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt2&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;12&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;GridView1.header = GridView.Horizontal&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt1&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;13&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;GridView1.grid = TRUE&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt2&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;14&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;GridView1.Rows.count = 0&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt1&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;15&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;GridView1.Columns.count = 2&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt2&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;16&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;GridView1.Columns[0].text = &quot;ID&quot;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt1&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;17&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;GridView1.Columns[1].text = &quot;Value&quot;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt2&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;18&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;GridView1.Columns[0].width = 55&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt1&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;19&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;GridView1.Columns[1].width = 55&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt2&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;20&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt1&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;21&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt2&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;22&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;WITH $hConn&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt1&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;23&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;.Type = &quot;sqlite&quot;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt2&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;24&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;.host = User.home&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt1&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;25&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;.name = &quot;&quot;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt2&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;26&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;END WITH &lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt1&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;27&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt2&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;28&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;&#39;delete an existing test.sqlite&amp;nbsp; &lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt1&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;29&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;IF Exist(User.home &amp;amp; &quot;/test.sqlite&quot;) THEN &lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt2&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;30&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;KILL User.home &amp;amp; &quot;/test.sqlite&quot;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt1&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;31&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;ENDIF &lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt2&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;32&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt1&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;33&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;&#39;create test.sqlite&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt2&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;34&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;$hConn.Open&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt1&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;35&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;$hConn.Databases.Add(&quot;test.sqlite&quot;)&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt2&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;36&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;$hconn.Close&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt1&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;37&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt2&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;38&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;&#39;define the table sampleTable&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt1&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;39&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;$hconn.name = &quot;test.sqlite&quot;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt2&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;40&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;$hConn.Open&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt1&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;41&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;hTable = $hConn.Tables.Add(&quot;sampleTable&quot;)&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt2&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;42&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;hTable.Fields.Add(&quot;s_seq&quot;, db.Integer)&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt1&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;43&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;hTable.Fields.Add(&quot;s_rndm&quot;, db.Integer)&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt2&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;44&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;hTable.PrimaryKey = [&quot;s_seq&quot;]&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt1&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;45&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;hTable.Update&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt2&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;46&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt1&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;47&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;&#39;fill the table with generated data&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt2&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;48&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;$hconn.Begin&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt1&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;49&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;rTest = $hConn.Create(&quot;sampleTable&quot;)&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt2&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;50&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;FOR iCount = 1 TO 10000&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt1&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;51&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;rTest!s_seq = iCount&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt2&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;52&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;rTest!s_rndm = Int(Rnd(0, 100))&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt1&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;53&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;rTest.Update&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt2&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;54&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;NEXT&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt1&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;55&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;$hConn.Commit&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt2&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;56&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt1&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;57&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;&#39;read the database&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt2&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;58&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;sql = &quot;select s_seq as ID, s_rndm as Value from sampleTable&quot;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt1&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;59&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;$res = $hconn.Exec(sql)&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt2&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;60&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt1&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;61&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;CATCH &lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt2&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;62&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;$hConn.Rollback&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt1&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;63&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;Message.Error(DConv(Error.Text))&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt2&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;64&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt1&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;65&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;END&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt2&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;66&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;&#39;-------------------------------------------------&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt1&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;67&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;PUBLIC SUB Form_Activate()&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt2&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;68&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;&#39;change the rowcount of the gridview from 0 to the number of records. &lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt1&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;69&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;&#39;This triggers the data handling event&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt2&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;70&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;GridView1.Rows.Count = $res.Count&amp;nbsp; &lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt1&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;71&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;END&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt2&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;72&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;&#39;-------------------------------------------------&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt1&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;73&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;PUBLIC SUB GridView1_Data(Row AS Integer, Column AS Integer)&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt2&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;74&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;$res.moveTo(row)&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt1&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;75&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;GridView1.Data.text = Str($res[GridView1.Columns[column].text])&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt2&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;76&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;END&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt1&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;77&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;&#39;-------------------------------------------------&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt2&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;78&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;PUBLIC SUB Form_Close()&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt1&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;79&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain plain&quot;&gt;$hconn.Close&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt2&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;80&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;END&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line alt1&quot;&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;81&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain plain&quot;&gt;&#39;-------------------------------------------------&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;We initially set the row count of the gridview to 0. Having read the  database into result $res, it will have 10000 records. In other words  $res.count=10000. Setting GridView1.Rows.Count = $res.Count will make  the gridview (which you have put on the form) a window to this grid of  1000 rows by 2 columns. The fact that empty cells are now displayed in  this window to a much bigger grid causes the gridview object to  repeatedly call Gridview1_data for each empty cell in view. The event  then fills the value of the blank cell from the equivalent value in the  result set. In no time at all every blank cell is filled with the  corresponding data from the result set.&lt;br /&gt;
If you scroll down the gridview, it exposes empty cells in the grid  which are automatically filled by the data handling event. And so on.&lt;br /&gt;
You could load all the available data into the gridview in one step  but it would take an unacceptably long time. This method gives the  impression of blinding speed by only loading the gridview cell values  which are visible. It’s just so clever.&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gambas-data-grid-codes-database.blogspot.com/feeds/7168150813700718656/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gambas-data-grid-codes-database.blogspot.com/2012/02/gridview1-or-gambas-data-grid.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7940058950332398351/posts/default/7168150813700718656'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7940058950332398351/posts/default/7168150813700718656'/><link rel='alternate' type='text/html' href='http://gambas-data-grid-codes-database.blogspot.com/2012/02/gridview1-or-gambas-data-grid.html' title='Gridview1 or gambas data grid'/><author><name>Allsearchengines.blogspot.com</name><uri>http://www.blogger.com/profile/11174269673917299671</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDdRnmNEk1Cp57AEcyvDr0xIJUe31vfRyGDqSRrBTu4iWfHkMJOy6wDjAkD4kbsGlkUggE6ftsFne7EGiSX-0a2VqNGHX0VQbPkVeENtRbworeumQhmIVi4S9fjgifgLs/s220/25299_1188449160606_1509634281_30384185_4723363_a.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7940058950332398351.post-3163161525289872945</id><published>2012-02-18T04:55:00.000-08:00</published><updated>2012-02-18T04:55:16.914-08:00</updated><title type='text'>Gambas datagrid</title><content type='html'>&lt;h1&gt;Gambas data grid code not connected to a database&lt;/h1&gt;Private Sub PopulateCharges() &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Dim intRow As Integer = 0 &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Dim strType As String = &quot;&quot; &lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;If rsCharges.Available Then &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;rsCharges.MoveFirst &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;grdCharge.Rows.Count = rsCharges.Count &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;For Each rsCharges &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;  &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;grdCharge[intRow, 0].Text =  rsCharges!unique_id &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;  &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;grdCharge[intRow, 1].Text =  rsCharges!charge_source &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;  &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;grdCharge[intRow, 2].Text =  rsCharges!charge_type &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;  &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;grdCharge[intRow, 3].Text =  rsCharges!charge_start &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;  &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;grdCharge[intRow, 4].Text =  rsCharges!charge_end &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;grdCharge[intRow, 5].Text =  &lt;br /&gt;
rsCharges!charge_display &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Inc intRow &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Next &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;modMain.UpdateStatus(rsCharges.Count &amp;amp; &quot; Charge records  &lt;br /&gt;
returned&quot;) &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;LoadChargeCombos(rsCharges) &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;grdCharge.Row = intRow - 1 &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Endif &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Catch &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Message.Error(Error.Class.Name &amp;amp; &quot;: &quot; &amp;amp; Error.Where &amp;amp; &quot;: &quot;  &lt;br /&gt;
&amp;amp; Error.Text) &lt;br /&gt;
End &lt;br /&gt;
&lt;br /&gt;
I assume you have got your recordset (rsCharges) from the Db. You ned to  &lt;br /&gt;
check how many rows are need in the grid and set this. Then populate  &lt;br /&gt;
each row and column as above.</content><link rel='replies' type='application/atom+xml' href='http://gambas-data-grid-codes-database.blogspot.com/feeds/3163161525289872945/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gambas-data-grid-codes-database.blogspot.com/2012/02/gambas-datagrid.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7940058950332398351/posts/default/3163161525289872945'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7940058950332398351/posts/default/3163161525289872945'/><link rel='alternate' type='text/html' href='http://gambas-data-grid-codes-database.blogspot.com/2012/02/gambas-datagrid.html' title='Gambas datagrid'/><author><name>Allsearchengines.blogspot.com</name><uri>http://www.blogger.com/profile/11174269673917299671</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDdRnmNEk1Cp57AEcyvDr0xIJUe31vfRyGDqSRrBTu4iWfHkMJOy6wDjAkD4kbsGlkUggE6ftsFne7EGiSX-0a2VqNGHX0VQbPkVeENtRbworeumQhmIVi4S9fjgifgLs/s220/25299_1188449160606_1509634281_30384185_4723363_a.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7940058950332398351.post-4615521121055629869</id><published>2012-02-18T04:45:00.000-08:00</published><updated>2012-02-18T04:45:06.623-08:00</updated><title type='text'>Gambas Sample data grid program mysql db connected</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpe1fGFk454qGBBI-ZQaHQYRizfh8BJBcoZNPFPtUxvvYwINE7cQL9kvmiXKtkf6pUt6cN1WxzNdDxSR77nqHw1eDQQtEomihRSU5gYllqMT6gKmdID3vdfLu4T1Gjb4kiyhfVPZ_UVL0/s1600/Screenshot.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;187&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpe1fGFk454qGBBI-ZQaHQYRizfh8BJBcoZNPFPtUxvvYwINE7cQL9kvmiXKtkf6pUt6cN1WxzNdDxSR77nqHw1eDQQtEomihRSU5gYllqMT6gKmdID3vdfLu4T1Gjb4kiyhfVPZ_UVL0/s320/Screenshot.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&#39; Gambas class file&lt;br /&gt;
PUBLIC MyConn AS Connection&amp;nbsp; &lt;br /&gt;
PUBLIC MyRS AS Result&amp;nbsp; &lt;br /&gt;
PUBLIC vCari AS String&amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
PUBLIC SUB Form_Open()&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; DIM iCount AS Integer&lt;br /&gt;
&amp;nbsp; DIM hTable AS Table&lt;br /&gt;
&amp;nbsp; DIM sql AS String&lt;br /&gt;
&amp;nbsp; DIM rsSuperMarket AS Result&lt;br /&gt;
&amp;nbsp; DIM intRow AS Integer = 0&lt;br /&gt;
&amp;nbsp; DIM strType AS String = &quot;&quot;&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp; &#39;define the gridview layout&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; GridView1.header = GridView.Horizontal&lt;br /&gt;
&amp;nbsp; GridView1.grid = TRUE&lt;br /&gt;
&amp;nbsp; GridView1.Rows.count = 2&lt;br /&gt;
&amp;nbsp; GridView1.Columns.count = 4&lt;br /&gt;
&amp;nbsp; GridView1.Columns[0].text = &quot;Pin&quot;&lt;br /&gt;
&amp;nbsp; GridView1.Columns[1].text = &quot;Description&quot;&lt;br /&gt;
&amp;nbsp; GridView1.Columns[2].text = &quot;Quantity&quot;&lt;br /&gt;
&amp;nbsp; GridView1.Columns[3].text = &quot;Prize&quot;&lt;br /&gt;
&amp;nbsp; GridView1.Columns[0].width = 100&lt;br /&gt;
&amp;nbsp; GridView1.Columns[1].width = 100&lt;br /&gt;
&amp;nbsp; GridView1.Columns[2].width = 100&lt;br /&gt;
&amp;nbsp; GridView1.Columns[3].width = 100&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &#39;define the table SuperMarket for the data grid to be able to read. My &#39;SuperMarketInventory, database has four records(Pin, Description, Quantity and Prize.) &lt;br /&gt;
rsSuperMarket is the variable where records from MYSQL pass through.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; rsSuperMarket = MyConn.Exec(&quot;SELECT * FROM SuperMarket&quot;) &#39;executing query &lt;br /&gt;
&amp;nbsp;&amp;nbsp; IF rsSuperMarket.Available THEN&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rsSuperMarket.MoveNext&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GridView1.Rows.Count = rsSuperMarket.Count&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FOR EACH rsSuperMarket &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GridView1[intRow, 0].Text = rsSuperMarket!Pin &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GridView1[intRow, 1].Text = rsSuperMarket!Description&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GridView1[intRow, 2].Text = rsSuperMarket!Quantity&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GridView1[intRow, 3].Text = rsSuperMarket!Prize&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&#39;INC intRow is a very important code that fills the table with generated data.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; INC intRow &lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NEXT&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyConn.Quote(rsSuperMarket.Count &amp;amp; &quot; Charge records returned&quot;)&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
ENDIF &lt;br /&gt;
END&lt;br /&gt;
&lt;br /&gt;
PUBLIC SUB Label1_MouseDown()&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
END&lt;br /&gt;
&lt;br /&gt;
PUBLIC SUB Label2_MouseDown()&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
END&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
PUBLIC SUB txtPin_Leave()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
END&lt;br /&gt;
&lt;br /&gt;
PUBLIC SUB txtPin_KeyPress()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
END&lt;br /&gt;
&lt;br /&gt;
PUBLIC SUB btnClear_Click()&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; txtPin.text = &quot;&quot;&amp;nbsp; &lt;br /&gt;
&amp;nbsp; txtDescription.text = &quot;&quot;&amp;nbsp; &lt;br /&gt;
&amp;nbsp; txtQuantity.text = &quot;&quot;&amp;nbsp; &lt;br /&gt;
&amp;nbsp; txtPrize.text = &quot;&quot;&lt;br /&gt;
END&lt;br /&gt;
&lt;br /&gt;
PRIVATE SUB clear()&amp;nbsp; &lt;br /&gt;
&amp;nbsp; txtPin.text = &quot;&quot;&amp;nbsp; &lt;br /&gt;
&amp;nbsp; txtDescription.text = &quot;&quot;&amp;nbsp; &lt;br /&gt;
&amp;nbsp; txtQuantity.text = &quot;&quot;&amp;nbsp; &lt;br /&gt;
&amp;nbsp; txtPrize.text = &quot;&quot;&lt;br /&gt;
END &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
PUBLIC SUB _new()&amp;nbsp; &lt;br /&gt;
&amp;nbsp; ME.center&amp;nbsp; &lt;br /&gt;
&amp;nbsp; DBConnect&amp;nbsp; &lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
END&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
PUBLIC SUB DBConnect()&amp;nbsp; &lt;br /&gt;
&amp;nbsp; MyConn = NEW Connection&amp;nbsp; &lt;br /&gt;
&amp;nbsp; MyConn.Close&amp;nbsp; &lt;br /&gt;
&amp;nbsp; MyConn.Type = &quot;mysql&quot;&amp;nbsp; &lt;br /&gt;
&amp;nbsp; MyConn.Host = &quot;localhost&quot;&amp;nbsp; &lt;br /&gt;
&amp;nbsp; MyConn.Login = &quot;root&quot;&amp;nbsp; &lt;br /&gt;
&amp;nbsp; MyConn.Password = &quot;1111&quot;&amp;nbsp; &lt;br /&gt;
&amp;nbsp; MyConn.Name = &quot;SuperMarketInventory&quot;&amp;nbsp; &lt;br /&gt;
&amp;nbsp; MyConn.Open&amp;nbsp; &lt;br /&gt;
CATCH&amp;nbsp; &lt;br /&gt;
&amp;nbsp; Message.error(Error.text)&amp;nbsp; &lt;br /&gt;
END&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
PUBLIC SUB _free()&amp;nbsp; &lt;br /&gt;
MyConn.Close&amp;nbsp; &lt;br /&gt;
Message.Info(&quot;Close. &quot;)&amp;nbsp; &lt;br /&gt;
&amp;nbsp;END&amp;nbsp; &lt;br /&gt;
#&amp;nbsp; &#39;End of program&amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
PUBLIC SUB btnClose_Click()&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; FMain.Close&lt;br /&gt;
&lt;br /&gt;
END&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
PUBLIC SUB btnAdd_Click()&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DIM MyRS AS String&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DIM sql AS String&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyRS = &quot;insert into Super (Pin, Description, Quantity, Prize )values( &#39;&quot; &amp;amp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; txtPin.text &amp;amp; &quot;&#39;,&#39;&quot; &amp;amp; txtDescription.text &amp;amp; &quot;&#39;,&#39;&quot; &amp;amp; txtQuantity.text &amp;amp; &quot;&#39;,&#39;&quot; &amp;amp;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; txtPrize.text &amp;amp; &quot;&#39;)&quot;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyRS = MyConn.Exec(sql)&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sql = &quot;update Super set &quot;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sql = sql &amp;amp; &quot;Pin = &#39;&quot; &amp;amp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; txtPin.text&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sql = sql &amp;amp; &quot;&#39;,Description = &#39;&quot; &amp;amp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; txtDescription.text&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sql = sql &amp;amp; &quot;&#39;,Quantity = &#39;&quot; &amp;amp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; txtQuantity.text&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sql = sql &amp;amp; &quot;&#39;,Prize = &#39;&quot; &amp;amp; txtPrize.text &amp;amp; &quot;&#39; where Pin = &quot; &amp;amp; vCari&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyRS = MyConn.Exec(sql)&amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
CATCH&amp;nbsp; &lt;br /&gt;
Message.Error(Error.Text) &lt;br /&gt;
&lt;br /&gt;
END&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
PUBLIC SUB btnCreateTable_Click()&lt;br /&gt;
&amp;nbsp; DIM hTable AS Table&lt;br /&gt;
&amp;nbsp; Myconn.name = &quot;SuperMarketInventory&quot;&lt;br /&gt;
&amp;nbsp; hTable = MyConn.Tables.Add(&quot;SuperMarket&quot;)&lt;br /&gt;
&amp;nbsp; hTable.Fields.Add(&quot;Pin&quot;, db.Integer)&lt;br /&gt;
&amp;nbsp; hTable.Fields.Add(&quot;Description&quot;, db.String)&lt;br /&gt;
&amp;nbsp; hTable.Fields.Add(&quot;Quantity&quot;, db.Integer)&lt;br /&gt;
&amp;nbsp; hTable.Fields.Add(&quot;Prize&quot;, db.Integer)&lt;br /&gt;
&amp;nbsp; hTable.Update&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
END</content><link rel='replies' type='application/atom+xml' href='http://gambas-data-grid-codes-database.blogspot.com/feeds/4615521121055629869/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gambas-data-grid-codes-database.blogspot.com/2012/02/gambas-sample-data-grid-program-mysql.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7940058950332398351/posts/default/4615521121055629869'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7940058950332398351/posts/default/4615521121055629869'/><link rel='alternate' type='text/html' href='http://gambas-data-grid-codes-database.blogspot.com/2012/02/gambas-sample-data-grid-program-mysql.html' title='Gambas Sample data grid program mysql db connected'/><author><name>Allsearchengines.blogspot.com</name><uri>http://www.blogger.com/profile/11174269673917299671</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDdRnmNEk1Cp57AEcyvDr0xIJUe31vfRyGDqSRrBTu4iWfHkMJOy6wDjAkD4kbsGlkUggE6ftsFne7EGiSX-0a2VqNGHX0VQbPkVeENtRbworeumQhmIVi4S9fjgifgLs/s220/25299_1188449160606_1509634281_30384185_4723363_a.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpe1fGFk454qGBBI-ZQaHQYRizfh8BJBcoZNPFPtUxvvYwINE7cQL9kvmiXKtkf6pUt6cN1WxzNdDxSR77nqHw1eDQQtEomihRSU5gYllqMT6gKmdID3vdfLu4T1Gjb4kiyhfVPZ_UVL0/s72-c/Screenshot.png" height="72" width="72"/><thr:total>0</thr:total></entry></feed>