<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>

<channel>
	<title>All About .NET</title>
	<atom:link href="http://dotnet.tekyt.info/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://dotnet.tekyt.info</link>
	<description>My Experience with .NET</description>
	<pubDate>Mon, 06 Sep 2010 10:07:47 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<item>
		<title>My Blog on Flex</title>
		<link>http://dotnet.tekyt.info/?p=38</link>
		<comments>http://dotnet.tekyt.info/?p=38#comments</comments>
		<pubDate>Mon, 07 Dec 2009 08:13:08 +0000</pubDate>
		<dc:creator>tuse</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://dotnet.tekyt.info/?p=38</guid>
		<description><![CDATA[<script type="text/javascript">dzone_url = "http://dotnet.tekyt.info/?p=38";</script>I have started to blog on Adobe Flex: http://flex.tekyt.info
If you have any comments / questions about any post related to this blog, feel free to e-mail me at: shreyastonse@gmail.com
var dzone_style="2";<script type="text/javascript">SHARETHIS.addEntry({ title: "My Blog on Flex", url: "http://dotnet.tekyt.info/?p=38" });</script>]]></description>
			<content:encoded><![CDATA[<script type="text/javascript">dzone_url = "http://dotnet.tekyt.info/?p=38";</script><p>I have started to blog on Adobe Flex: <a href="http://flex.tekyt.info" target="_blank">http://flex.tekyt.info</a></p>
<p>If you have any comments / questions about any post related to this blog, feel free to e-mail me at: shreyastonse@gmail.com</p>
<script>var dzone_style="2";</script><script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script><p><a href="http://sharethis.com/item?&wp=2.5.1&amp;publisher=64f9dad7-a01a-431a-be35-77c065f806c3&amp;title=My+Blog+on+Flex&amp;url=http%3A%2F%2Fdotnet.tekyt.info%2F%3Fp%3D38">ShareThis</a></p>]]></content:encoded>
			<wfw:commentRss>http://dotnet.tekyt.info/?feed=rss2&amp;p=38</wfw:commentRss>
		</item>
		<item>
		<title>Using a DataGridView</title>
		<link>http://dotnet.tekyt.info/?p=37</link>
		<comments>http://dotnet.tekyt.info/?p=37#comments</comments>
		<pubDate>Sun, 19 Oct 2008 07:25:32 +0000</pubDate>
		<dc:creator>tuse</dc:creator>
		
		<category><![CDATA[ASP.NET]]></category>

		<category><![CDATA[Databases]]></category>

		<category><![CDATA[VB.NET]]></category>

		<category><![CDATA[datagridview]]></category>

		<guid isPermaLink="false">http://dotnet.tekyt.info/?p=37</guid>
		<description><![CDATA[<script type="text/javascript">dzone_url = "http://dotnet.tekyt.info/?p=37";</script>The DataGridView Control Control can be used to display the contents of a table from the database as per an SQL query of user&#8217;s choice.
Let us see an example, add a DataGridView from the ToolBox to a new Windows Form.
When the Form Loads, we will look to fill the DGV with the following code-


Dim cmd [...]<script type="text/javascript">SHARETHIS.addEntry({ title: "Using a DataGridView", url: "http://dotnet.tekyt.info/?p=37" });</script>]]></description>
			<content:encoded><![CDATA[<script type="text/javascript">dzone_url = "http://dotnet.tekyt.info/?p=37";</script><p>The DataGridView Control Control can be used to display the contents of a table from the database as per an SQL query of user&#8217;s choice.</p>
<p>Let us see an example, add a DataGridView from the ToolBox to a new Windows Form.</p>
<p>When the Form Loads, we will look to fill the DGV with the following code-</p>
<pre name="code" class="vb.net">

Dim cmd As New Odbc.OdbcCommand("Select number as 'Book Number',title as 'Book Name', author as 'Author', publisher as 'Publisher', no_of_copies as 'No. of Copies', number_issued as 'No Issued', sub_category as 'Sub Category',edition as 'Edition' from book_details", cn)

'cn is the ODBC Connection Object defined in earlier posts

        Dim adp As Odbc.OdbcDataAdapter
        adp = New Odbc.OdbcDataAdapter(cmd)
        Dim ds As New DataSet
        adp.Fill(ds, "book_details")
        Me.DataGridView1.DataSource = ds
        Me.DataGridView1.DataMember = "book_details"
        Me.DataGridView1.AutoResizeColumns()
</pre>
<p>We are using a DataSet-the core of the ADO.NET disconnected architecture and is used to store data in a disconnected state. In accordance to the SQL query, the DataSet is filled using the DataAdapter (adp).</p>
<p>The DataGridView comes with several options- enabling the user to edit records, add records, delete records. </p>
<p>In order to retrive data displayed in the DataGridView we can use the following code- this piece of code is very useful and I have used it on several occasions:</p>
<pre name="code" class="vb.net">

Dim i As Integer
        i = DataGridView1.CurrentRow.Index
        Dim book_number as Integer  = DataGridView1.Item(0, i).Value
        </pre>
<p>        What we are doing in this piece of code is that we are are holding the current row&#8217;s index number in the variable <em>i </em>and thereafter the item in the first column in the variable <em>book_number</em></p>
<script>var dzone_style="2";</script><script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script><p><a href="http://sharethis.com/item?&wp=2.5.1&amp;publisher=64f9dad7-a01a-431a-be35-77c065f806c3&amp;title=Using+a+DataGridView&amp;url=http%3A%2F%2Fdotnet.tekyt.info%2F%3Fp%3D37">ShareThis</a></p>]]></content:encoded>
			<wfw:commentRss>http://dotnet.tekyt.info/?feed=rss2&amp;p=37</wfw:commentRss>
		</item>
		<item>
		<title>Using XML in .NET</title>
		<link>http://dotnet.tekyt.info/?p=36</link>
		<comments>http://dotnet.tekyt.info/?p=36#comments</comments>
		<pubDate>Sat, 02 Aug 2008 16:10:45 +0000</pubDate>
		<dc:creator>tuse</dc:creator>
		
		<category><![CDATA[ASP.NET]]></category>

		<category><![CDATA[Tools]]></category>

		<category><![CDATA[VB.NET]]></category>

		<category><![CDATA[dataset]]></category>

		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://dotnet.tekyt.info/?p=36</guid>
		<description><![CDATA[<script type="text/javascript">dzone_url = "http://dotnet.tekyt.info/?p=36";</script>We will see how we can use XML files in a VB.NET application. XML is used in many aspects of web development, often to simplify data storage.
In a Windows form, add a DataGridView and a Button. Change the text of this Button as &#8216;Save&#8217;.
The XML file that I am interested in-

    


 [...]<script type="text/javascript">SHARETHIS.addEntry({ title: "Using XML in .NET", url: "http://dotnet.tekyt.info/?p=36" });</script>]]></description>
			<content:encoded><![CDATA[<script type="text/javascript">dzone_url = "http://dotnet.tekyt.info/?p=36";</script><p>We will see how we can use XML files in a VB.NET application. <em>XML</em> is used in many aspects of web development, often to simplify data storage.</p>
<p>In a Windows form, add a DataGridView and a Button. Change the text of this Button as &#8216;Save&#8217;.</p>
<p>The XML file that I am interested in-</p>
<pre class="xml" name="code">
    <?xml version="1.0" standalone="yes"?>
<student>

  <freshman>
    <name>John Smith</name>
    <branch>Computers</branch>
  </freshman>

  <freshman>
    <name>Matthew Max</name>
    <branch>Electrical</branch>
  </freshman>

  <freshman>
    <name>Jay Yan</name>
    <branch>Mechanical</branch>
  </freshman>

</student>
</pre>
<p>The XML file that I have holds freshman records studying in an engineering school. We will look to display the fields &#8216;name&#8217; and &#8216;branch&#8217; in the DataGridView.</p>
<p>The &#8216;Save&#8217; button should be able to save the changes made to the records in the DataGridView in the XML file.</p>
<p>We shall use a DataSet for reading the XML file. The Save Button will involve the Write function to the XML file invoked using the dataset.</p>
<p>The code-</p>
<pre class="vb.net" name="code">Public Class Form1

    Dim ds As DataSet

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ds = New DataSet
        ds.ReadXml("C:\myxml\file1.xml") 'Path where your XML file exists on the system
        Me.DataGridView1.DataSource = ds
        Me.DataGridView1.DataMember = "freshman" 'Records that you wish to display. Look at the XML file for reference
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        ds.WriteXml("C:\myxml\file1.xml") 'Save the changes made in the DataGridView to be reflected in the XML file
    End Sub
End Class
</pre>
<p>This is an illustration of the usage of XML in VB.NET. You may use this in ASP.NET too. In order to specify the source for the file on the server, you may use <em>&#8216;Server.MapPath()&#8217;</em> to specify the path for your XML file.</p>
<script>var dzone_style="2";</script><script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script><p><a href="http://sharethis.com/item?&wp=2.5.1&amp;publisher=64f9dad7-a01a-431a-be35-77c065f806c3&amp;title=Using+XML+in+.NET&amp;url=http%3A%2F%2Fdotnet.tekyt.info%2F%3Fp%3D36">ShareThis</a></p>]]></content:encoded>
			<wfw:commentRss>http://dotnet.tekyt.info/?feed=rss2&amp;p=36</wfw:commentRss>
		</item>
		<item>
		<title>Console Applications</title>
		<link>http://dotnet.tekyt.info/?p=35</link>
		<comments>http://dotnet.tekyt.info/?p=35#comments</comments>
		<pubDate>Fri, 01 Aug 2008 16:13:23 +0000</pubDate>
		<dc:creator>tuse</dc:creator>
		
		<category><![CDATA[Console]]></category>

		<category><![CDATA[VB.NET]]></category>

		<category><![CDATA[visual studio]]></category>

		<guid isPermaLink="false">http://dotnet.tekyt.info/?p=35</guid>
		<description><![CDATA[<script type="text/javascript">dzone_url = "http://dotnet.tekyt.info/?p=35";</script>Visual Studio lets you develop Console Applications as well. Console Applications are command-line applications similar to C or Java programs. These applications allow you to take input, display characters on a DOS window.
In order to develop a Console Application, start Visual Studio, point to New Project and select &#8216;Console Application&#8217;.
The System.Console namespace supports the creation [...]<script type="text/javascript">SHARETHIS.addEntry({ title: "Console Applications", url: "http://dotnet.tekyt.info/?p=35" });</script>]]></description>
			<content:encoded><![CDATA[<script type="text/javascript">dzone_url = "http://dotnet.tekyt.info/?p=35";</script><p>Visual Studio lets you develop Console Applications as well. Console Applications are command-line applications similar to C or Java programs. These applications allow you to take input, display characters on a DOS window.</p>
<p>In order to develop a Console Application, start Visual Studio, point to New Project and select &#8216;Console Application&#8217;.</p>
<p>The System.Console namespace supports the creation of Console Applications.</p>
<p>As with C and Java, the program execution begins with the Sub Main() - the entry point of the program.</p>
<pre class="vb.net" name="code">
Module Module1
Sub Main()
Dim nm As String
System.Console.Write("Enter your name: ")
nm = System.Console.ReadLine()
System.Console.WriteLine("Your name is: " &#038; nm)
System.Console.ReadLine()
End Sub
End Module
</pre>
<p>This simple program accepts a string from the user and displays it on the console. As you can see, the code is quite similar to a program written in Java. In order to execute this program, press F5/ Debug-&gt;Start.</p>
<p>A DOS window pops up asking you to enter your name. This is due to the <em>&#8216;System.Console.Write()&#8217;</em>&#8216; method.</p>
<p>Similarly, <em>&#8216;System.Console.ReadLine()&#8217; </em>is used to read a line from the console. The final <em>&#8216;System.Console.ReadLine()&#8217; </em>is like the getch() used in C programs so that the console &#8216;waits&#8217; for a keypress before termination.</p>
<script>var dzone_style="2";</script><script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script><p><a href="http://sharethis.com/item?&wp=2.5.1&amp;publisher=64f9dad7-a01a-431a-be35-77c065f806c3&amp;title=Console+Applications&amp;url=http%3A%2F%2Fdotnet.tekyt.info%2F%3Fp%3D35">ShareThis</a></p>]]></content:encoded>
			<wfw:commentRss>http://dotnet.tekyt.info/?feed=rss2&amp;p=35</wfw:commentRss>
		</item>
		<item>
		<title>Creating User Defined Controls in VB.NET</title>
		<link>http://dotnet.tekyt.info/?p=32</link>
		<comments>http://dotnet.tekyt.info/?p=32#comments</comments>
		<pubDate>Fri, 18 Jul 2008 18:21:35 +0000</pubDate>
		<dc:creator>prasu</dc:creator>
		
		<category><![CDATA[Technical]]></category>

		<category><![CDATA[VB.NET]]></category>

		<category><![CDATA[banner control]]></category>

		<category><![CDATA[controls]]></category>

		<category><![CDATA[user defined controls]]></category>

		<guid isPermaLink="false">http://dotnet.tekyt.info/?p=32</guid>
		<description><![CDATA[<script type="text/javascript">dzone_url = "http://dotnet.tekyt.info/?p=32";</script>In many applications we need tailor-made controls to suit our programming needs. Such controls can be created in VB.NET.

To create a user-defined control you have to use Windows Control Libray.
Go to file &#8211;&#62; New Project&#8211;&#62; Windows Forms Contol Library &#8211;&#62; (Give any desired name to your project) &#8211;&#62; Ok.
You will find a Canvas. Now using [...]<script type="text/javascript">SHARETHIS.addEntry({ title: "Creating User Defined Controls in VB.NET", url: "http://dotnet.tekyt.info/?p=32" });</script>]]></description>
			<content:encoded><![CDATA[<script type="text/javascript">dzone_url = "http://dotnet.tekyt.info/?p=32";</script><p>In many applications we need tailor-made controls to suit our programming needs. Such controls can be created in VB.NET.</p>
<ol>
<li>To create a user-defined control you have to use Windows Control Libray.<br />
Go to file &#8211;&gt; New Project&#8211;&gt; Windows Forms Contol Library &#8211;&gt; (Give any desired name to your project) &#8211;&gt; Ok.</li>
<li>You will find a Canvas. Now using the controls present in the toolbox create the required component (control).</li>
<li>Code the Control as you want it to work.</li>
<li>You can add user defined properties by using <strong>property</strong> keyword.</li>
<li>The size of the canvas is the size of the user defined control you are creating. So change the canvas size as required at the end.</li>
<li>After you have written the code check the control by debugging the project.</li>
<li>Now go to Build &#8211;&gt; Build &lt;component name&gt;.</li>
<li>To add the Component (control) in the toolbox, right click in the empty area of the Toolbox &#8211;&gt; Choose Items &#8211;&gt; Click on browse. (This should be in a new VB.NET Windows Application)<br />
Go to the Project Folder (This time, its the Control Library Project you created) &#8211;&gt; Bin &#8211;&gt; Debug &#8211;&gt; Select &lt;componentname&gt;.dll file<br />
Check the Component name in .NET Framework Components Tab &#8211;&gt; OK.</li>
<li>The new Component (control) is added to your toolbox.</li>
</ol>
<p>Ex: Creating a text-flipping banner control.</p>
<ol>
<li>Create a windows library form and name it Banner.</li>
<li>In the Canvas drag two Textboxes and add a Timer.</li>
<li>Set the Timer&#8217;s enabled property true,Set the interval to say 1000 (unit:milliseconds).</li>
<li>Set some default Text in both the Textboxes.</li>
<li>Double click on the timer and write the below code.</li>
<li>Then write two properties named first and second which are used to change the text of the banner.</li>
<li>Drag one textbox on top of other and then reduce the canvas size such that it covers only the textboxes.</li>
<li>Debug the program, The Text of the banner oscillates between the two values of the textboxes.You can change the text of the first and second text box using property first and second respectively.</li>
<li>If it is working properly stop debugging and click on build &#8211;&gt; build banner.</li>
</ol>
<p align="center"><img src="http://dotnet.tekyt.info/Banner1.jpg" alt="" width="456" height="528" /></p>
<pre class="vb.net" name="code">
Public Class Banner

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Static f As Boolean
        If f = True Then
            Me.TextBox1.Visible = True
            Me.TextBox2.Visible = False
        Else
            Me.TextBox1.Visible = False
            Me.TextBox2.Visible = True
        End If
        f = Not f
    End Sub

    Public Property first() As String
        Get
            Return Me.TextBox1.Text
        End Get
        Set(ByVal value As String)
            Me.TextBox1.Text = value
        End Set
    End Property

    Public Property second() As String
        Get
            Return Me.TextBox2.Text
        End Get
        Set(ByVal value As String)
            Me.TextBox2.Text = value
        End Set
    End Property

End Class</pre>
<p>In the above code within a property we see two more keywords<br />
<strong>get</strong>:It returns a value to the caller.<br />
<strong>set</strong>:It sets the value to the given property.</p>
<script>var dzone_style="2";</script><script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script><p><a href="http://sharethis.com/item?&wp=2.5.1&amp;publisher=64f9dad7-a01a-431a-be35-77c065f806c3&amp;title=Creating+User+Defined+Controls+in+VB.NET&amp;url=http%3A%2F%2Fdotnet.tekyt.info%2F%3Fp%3D32">ShareThis</a></p>]]></content:encoded>
			<wfw:commentRss>http://dotnet.tekyt.info/?feed=rss2&amp;p=32</wfw:commentRss>
		</item>
		<item>
		<title>Online Examination System Project in ASP.NET</title>
		<link>http://dotnet.tekyt.info/?p=34</link>
		<comments>http://dotnet.tekyt.info/?p=34#comments</comments>
		<pubDate>Fri, 11 Jul 2008 15:11:28 +0000</pubDate>
		<dc:creator>tuse</dc:creator>
		
		<category><![CDATA[ASP.NET]]></category>

		<category><![CDATA[Databases]]></category>

		<category><![CDATA[asp.net project]]></category>

		<category><![CDATA[cookies]]></category>

		<category><![CDATA[disable browser back button]]></category>

		<category><![CDATA[exam project in asp.net]]></category>

		<category><![CDATA[mysql]]></category>

		<category><![CDATA[session variables]]></category>

		<guid isPermaLink="false">http://dotnet.tekyt.info/?p=34</guid>
		<description><![CDATA[<script type="text/javascript">dzone_url = "http://dotnet.tekyt.info/?p=34";</script>This is a project we made in ASP.NET. Its an examination system made in Visual Studio 2008 using a MySQL database. Please do take a look at it and suggest improvements. Also, if the project is vulnerable to any security threats, please do ping us back.
I hope you will like our attempt at coding this [...]<script type="text/javascript">SHARETHIS.addEntry({ title: "Online Examination System Project in ASP.NET", url: "http://dotnet.tekyt.info/?p=34" });</script>]]></description>
			<content:encoded><![CDATA[<script type="text/javascript">dzone_url = "http://dotnet.tekyt.info/?p=34";</script><p>This is a project we made in ASP.NET. Its an examination system made in Visual Studio 2008 using a MySQL database. Please do take a look at it and suggest improvements. Also, if the project is vulnerable to any security threats, please do ping us back.</p>
<p>I hope you will like our attempt at coding this application.</p>
<p><strong>Features-</strong></p>
<p>User first needs to supply valid credentials to begin the test.</p>
<p>Randomly chooses 5 questions from a database of 10 questions.</p>
<p>The test is a timed test, admin can change the duration of the test before it begins in the code.</p>
<p>Test-taker can leave a question un-answered and come back to the question (if time permits) using the &#8216;Previous&#8217; and &#8216;Next&#8217; Buttons.</p>
<p><strong>Code Details-</strong></p>
<p>1. Login is authenticated against a MySQL database.</p>
<p>2. AJAX is used for the timer, allowing only the timer label to postback to the server each second.</p>
<p>3. Use of the Random class to generate 5 questions out of the 10 in the database.</p>
<p>4. Session Management using Cookies and Session Variables.</p>
<p>5. Use of javascript in the master-page to prevent the &#8216;Back&#8217; navigation from a page (clearing the cache)  [Would love your suggestions on an alternative to this]</p>
<p>6. Once the 5 questions are chosen randomly, they are held in a DataTable. This is then held in a  Session Variable to hold the values during postbacks.</p>
<h2>
Get the project <a title="Online Examination System" href="http://dotnet.tekyt.info/wp-content/uploads/WebSite12.rar">here</a></h2>
<h2>
Get the database <a title="DataBase" href="http://dotnet.tekyt.info/wp-content/uploads/asp.sql.zip">here</a></h2>
<script>var dzone_style="2";</script><script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script><p><a href="http://sharethis.com/item?&wp=2.5.1&amp;publisher=64f9dad7-a01a-431a-be35-77c065f806c3&amp;title=Online+Examination+System+Project+in+ASP.NET&amp;url=http%3A%2F%2Fdotnet.tekyt.info%2F%3Fp%3D34">ShareThis</a></p>]]></content:encoded>
			<wfw:commentRss>http://dotnet.tekyt.info/?feed=rss2&amp;p=34</wfw:commentRss>
		</item>
		<item>
		<title>Connecting MySQL with .NET - Revisited</title>
		<link>http://dotnet.tekyt.info/?p=33</link>
		<comments>http://dotnet.tekyt.info/?p=33#comments</comments>
		<pubDate>Sun, 06 Jul 2008 17:57:12 +0000</pubDate>
		<dc:creator>prasu</dc:creator>
		
		<category><![CDATA[Databases]]></category>

		<category><![CDATA[Tips and Tricks]]></category>

		<category><![CDATA[.net]]></category>

		<category><![CDATA[mysql]]></category>

		<category><![CDATA[parameterized query]]></category>

		<guid isPermaLink="false">http://dotnet.tekyt.info/?p=33</guid>
		<description><![CDATA[<script type="text/javascript">dzone_url = "http://dotnet.tekyt.info/?p=33";</script>Today, I came across another way to connect to a MySQL database in .NET
This is done through MySQL Connector/Net (We are using v 5.1.6)
MySQL Connector provides a namespace &#8216;MySql.Data.MySqlClient&#8217; which gives you objects such as-
MySqlConnection - To establish a connection
MySqlCommand- Specify the MySQL Command
MySqlDataAdapter- Form the link between the dataset and the database
In order to [...]<script type="text/javascript">SHARETHIS.addEntry({ title: "Connecting MySQL with .NET - Revisited", url: "http://dotnet.tekyt.info/?p=33" });</script>]]></description>
			<content:encoded><![CDATA[<script type="text/javascript">dzone_url = "http://dotnet.tekyt.info/?p=33";</script><p>Today, I came across another way to connect to a MySQL database in .NET</p>
<p>This is done through MySQL Connector/Net (We are using v 5.1.6)</p>
<p>MySQL Connector provides a namespace <em>&#8216;MySql.Data.MySqlClient&#8217;</em> which gives you objects such as-</p>
<p>MySqlConnection - To establish a connection</p>
<p>MySqlCommand- Specify the MySQL Command</p>
<p>MySqlDataAdapter- Form the link between the dataset and the database</p>
<p>In order to be able to use these objects, you must first download the Connector from the MySQL website <a title="MySQL Connector" href="http://dev.mysql.com/downloads/connector/net/5.1.html">here</a></p>
<p>Therafter, in order to use this in your VB.NET Project, goto Project Menu -> Add Reference -> Under the .NET tab, Select MySQL.Data</p>
<p>You will need an import statement too as shown in the snippet that follows.<br />
The connection string in this case would change to-</p>
<pre class="vb.net"  name="code">

Server=127.0.0.1;Uid=&lt;username&gt;;Pwd=&lt;password&gt;;Database=&lt;database name&gt;;
</pre>
<p>Read the Documentation <a title="Documentation" href="http://dev.mysql.com/doc/refman/5.1/en/">here</a></p>
<p>One difference that is worthy of mention is the manner in which a parameterized query is constructed. It differs from the type we used earlier for ODBC. Here is a small snippet to illustrate the same-</p>
<pre class="vb.net" name="code">
Imports MySql.Data.MySqlClient

Dim cn As New MySqlConnection(" Server=127.0.0.1;Uid=root;Pwd=;Database=logindb;")
        Dim cmd As New MySqlCommand("select * from login where username=?user and password=?pass", cn)
        cmd.Parameters.Add("?username", MySqlDbType.VarChar, 80).Value = Me.TextBox1.Text
        cmd.Parameters.Add("?pass", MySqlDbType.VarChar, 80).Value = Me.TextBox2.Text
        Dim ds As New DataSet
        Dim adp As New MySqlDataAdapter(cmd)
        adp.Fill(ds, "login")
        Me.DataGridView1.DataSource = ds
        Me.DataGridView1.DataMember = "login"
</pre>
<script>var dzone_style="2";</script><script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script><p><a href="http://sharethis.com/item?&wp=2.5.1&amp;publisher=64f9dad7-a01a-431a-be35-77c065f806c3&amp;title=Connecting+MySQL+with+.NET+-+Revisited&amp;url=http%3A%2F%2Fdotnet.tekyt.info%2F%3Fp%3D33">ShareThis</a></p>]]></content:encoded>
			<wfw:commentRss>http://dotnet.tekyt.info/?feed=rss2&amp;p=33</wfw:commentRss>
		</item>
		<item>
		<title>Creating a Login in ASP.NET using a MySQL table</title>
		<link>http://dotnet.tekyt.info/?p=31</link>
		<comments>http://dotnet.tekyt.info/?p=31#comments</comments>
		<pubDate>Thu, 03 Jul 2008 11:08:47 +0000</pubDate>
		<dc:creator>tuse</dc:creator>
		
		<category><![CDATA[ASP.NET]]></category>

		<category><![CDATA[Databases]]></category>

		<category><![CDATA[database login]]></category>

		<category><![CDATA[login]]></category>

		<category><![CDATA[login control]]></category>

		<category><![CDATA[mysql]]></category>

		<category><![CDATA[ODBC]]></category>

		<guid isPermaLink="false">http://dotnet.tekyt.info/?p=31</guid>
		<description><![CDATA[<script type="text/javascript">dzone_url = "http://dotnet.tekyt.info/?p=31";</script>Today we will see how to create a simple login page for your ASP.NET website. Add a new WebForm to your Website. For readabilty, name this as login.aspx
Drag a Login control from the toolbox (Yes, ASP.NET comes with a built-in Login control)
This Login control is really smart and is able to do the validations itself [...]<script type="text/javascript">SHARETHIS.addEntry({ title: "Creating a Login in ASP.NET using a MySQL table", url: "http://dotnet.tekyt.info/?p=31" });</script>]]></description>
			<content:encoded><![CDATA[<script type="text/javascript">dzone_url = "http://dotnet.tekyt.info/?p=31";</script><p>Today we will see how to create a simple login page for your ASP.NET website. Add a new WebForm to your Website. For readabilty, name this as login.aspx</p>
<p>Drag a Login control from the toolbox (Yes, ASP.NET comes with a built-in Login control)</p>
<p>This Login control is really smart and is able to do the validations itself (i.e. checking if username and password are not entered etc..)</p>
<p>What needs to be configured for this control is the <strong>manner in which the user authentication will occur.</strong></p>
<p>We will authenticate a user using the data stored in a <strong>MySQL database</strong> in the <em>&#8216;login&#8217;</em> table which holds the username and password (We created this table and so should you before trying this out).</p>
<p>Write the following code for the <em>&#8216;Login1_Authenticate&#8217;</em> method. Double click on the Login control to goto the code window.</p>
<p>&nbsp;</p>
<pre class="vb.net" name="code">
' Import the ODBC namespace for MySQL Connection
Imports System.Data.Odbc
Partial Class login
    Inherits System.Web.UI.Page

    Protected Sub Login1_Authenticate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.AuthenticateEventArgs) Handles Login1.Authenticate
        Dim cn As New OdbcConnection("Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=mydb; User=root;Password=;")
        cn.Open()
        Dim cmd As New OdbcCommand("Select * from login where username=? and password=?", cn)

        'Add parameters to get the username and password

        cmd.Parameters.Add("@username", OdbcType.VarChar)
        cmd.Parameters("@username").Value = Me.Login1.UserName

        cmd.Parameters.Add("@password", OdbcType.VarChar)
        cmd.Parameters("@password").Value = Me.Login1.Password

        Dim dr As OdbcDataReader
        ' Initialise a reader to read the rows from the login table.
        ' If row exists, the login is successful

        dr = cmd.ExecuteReader

        If dr.HasRows Then
            e.Authenticated = True
            ' Event Authenticate is true
        End If

    End Sub
End Class
</pre>
<p>Now suppose that you have other webpages in your websites and you wish to grant access to these only if a user has authenticated himself. This essentially means that the login page should appear to any anonymous users trying to access the webpage. To do this, we need to change the <em>web.config</em> XML file associated with the website (It is a configuration file which is added by default to all ASP.NET websites). This file can be found from the Solution Explorer (Keyboard Shortcut - Ctrl+Alt+L).</p>
<p>Make the following changes to the authentication tag that already exists in the file to make it look like the following-
</p>
<pre class="xml" name="code">
<authentication mode="Forms" >
<forms name="AspxAuth" loginUrl="login.aspx" />
		</authentication >
        </pre>
<p>Add a authorization tag just after the authentication to make sure anonymous users are denied access to your webpages (Anonymous users are identified by the question mark)        </p>
<pre class="xml" name="code">
                                     <authorization>
			             <deny users ="?" />
                                     </authorization>
                                     <!-- Deny Anonymous Users Access to your pages -->
</pre>
<p>Now when you try to request any page in your website, it shows the <em>login.aspx</em> to authenticate you before allowing you to view its contents.</p>
<script>var dzone_style="2";</script><script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script><p><a href="http://sharethis.com/item?&wp=2.5.1&amp;publisher=64f9dad7-a01a-431a-be35-77c065f806c3&amp;title=Creating+a+Login+in+ASP.NET+using+a+MySQL+table&amp;url=http%3A%2F%2Fdotnet.tekyt.info%2F%3Fp%3D31">ShareThis</a></p>]]></content:encoded>
			<wfw:commentRss>http://dotnet.tekyt.info/?feed=rss2&amp;p=31</wfw:commentRss>
		</item>
		<item>
		<title>Introduction to PostBack in ASP.NET</title>
		<link>http://dotnet.tekyt.info/?p=30</link>
		<comments>http://dotnet.tekyt.info/?p=30#comments</comments>
		<pubDate>Wed, 02 Jul 2008 13:45:04 +0000</pubDate>
		<dc:creator>tuse</dc:creator>
		
		<category><![CDATA[ASP.NET]]></category>

		<category><![CDATA[auto postback]]></category>

		<category><![CDATA[postback]]></category>

		<guid isPermaLink="false">http://dotnet.tekyt.info/?p=30</guid>
		<description><![CDATA[<script type="text/javascript">dzone_url = "http://dotnet.tekyt.info/?p=30";</script>Today we are going to introduce you to the concept of PostBack in ASP.NET.
PostBack is the name given to the process of submitting an ASP.NET page to  the server for processing . PostBack is done if certain credentials of the page  are to be checked against a database (such as verification of username [...]<script type="text/javascript">SHARETHIS.addEntry({ title: "Introduction to PostBack in ASP.NET", url: "http://dotnet.tekyt.info/?p=30" });</script>]]></description>
			<content:encoded><![CDATA[<script type="text/javascript">dzone_url = "http://dotnet.tekyt.info/?p=30";</script><p>Today we are going to introduce you to the concept of PostBack in ASP.NET.</p>
<p>PostBack is the name given to the process of submitting an ASP.NET page to  the server for processing . PostBack is done if certain credentials of the page  are to be checked against a database (such as verification of username and  password). This is something that a client machine is not able to accomplish and  thus these details have to be <em>&#8216;posted back&#8217;</em> to the server.</p>
<p>A simple example to illustrate the usage of PostBack is a login page. After  the user has typed his username and password, he clicks on the <em>&#8216;Login&#8217;</em> button. Upon the click, the page is sent to the server to check against the  database/XML file to check if the user with supplied details is an authenticated  user.</p>
<p>Then there arise certain events ( Listbox Index Changed,RadioButton Checked  etc..) in an ASP.NET page upon which a PostBack might be needed. Consider the  case in which you have 2 ComboBoxes. Let us say the first ComboBox asks you for  the Country you reside in and the second one asks you for the State/Province in  that country. Based upon the Country you select, the list of States/Provinces  must be shown. Thus, in order to fill the values in the second ComboBox, the  selection in the first ComboBox must be known to the server. Thus, as and when  an item is selected in the first ComboBox, a PostBack must be done and the  appropriate list of items must be filled in the second ComboBox.</p>
<p>To handle these situations, you need to enable the<em> &#8216;Auto PostBack&#8217;</em> property for those controls whose events are going to trigger some kind of  server processing (the case of the first ComboBox in the previous example).</p>
<p>Usage of IsPostBack in ASP.NWT-</p>
<p>IsPostBack is a Boolean property of a page when is set (=true) when a page is  first loaded. Thus, the first time that the page loads the IsPostBack flag is false and  for subsequent PostBacks, it is true. An important point to be noted here is  that each time a PostBack occurs, the entire page including the <em>Page_Load</em> is <em>&#8216;posted back</em>&#8216; and executed.</p>
<p>Thus a very common programming practice is that whenever some part of the  code is to be executed just the first time a page loads, it is checked against  the IsPostBack flag.</p>
<p>If you have not understood the concept clearly, do not worry. Programming  examples in subsequent posts will help making this concept clear.</p>
<script>var dzone_style="2";</script><script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script><p><a href="http://sharethis.com/item?&wp=2.5.1&amp;publisher=64f9dad7-a01a-431a-be35-77c065f806c3&amp;title=Introduction+to+PostBack+in+ASP.NET&amp;url=http%3A%2F%2Fdotnet.tekyt.info%2F%3Fp%3D30">ShareThis</a></p>]]></content:encoded>
			<wfw:commentRss>http://dotnet.tekyt.info/?feed=rss2&amp;p=30</wfw:commentRss>
		</item>
		<item>
		<title>Binding Data To Controls</title>
		<link>http://dotnet.tekyt.info/?p=29</link>
		<comments>http://dotnet.tekyt.info/?p=29#comments</comments>
		<pubDate>Tue, 01 Jul 2008 16:24:41 +0000</pubDate>
		<dc:creator>prasu</dc:creator>
		
		<category><![CDATA[Databases]]></category>

		<category><![CDATA[Technical]]></category>

		<category><![CDATA[VB.NET]]></category>

		<category><![CDATA[controls]]></category>

		<category><![CDATA[databind]]></category>

		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://dotnet.tekyt.info/?p=29</guid>
		<description><![CDATA[<script type="text/javascript">dzone_url = "http://dotnet.tekyt.info/?p=29";</script>In practical applications it is not always convenient to retrieve data in DataGridView (as done in a previous example). Data can also be retrieved in a more elegant manner and bound to Controls like TextBoxes or Labels. For this purpose, we come across a new object type known as BindingSource.
Binding Source binds the data from [...]<script type="text/javascript">SHARETHIS.addEntry({ title: "Binding Data To Controls", url: "http://dotnet.tekyt.info/?p=29" });</script>]]></description>
			<content:encoded><![CDATA[<script type="text/javascript">dzone_url = "http://dotnet.tekyt.info/?p=29";</script><p>In practical applications it is not always convenient to retrieve data in DataGridView (as done in a previous example). Data can also be retrieved in a more elegant manner and bound to Controls like TextBoxes or Labels. For this purpose, we come across a new object type known as BindingSource.</p>
<p>Binding Source binds the data from a column in a table to a control.</p>
<p>For this example, we will be using the same table as we did for the DataGridView Example (my previous post)</p>
<p>Example:</p>
<ol>
<li>Drag three Labels, three Textboxes and two buttons to a new Windows form.</li>
<li>Change the text property of the three Labels to Name, City and Date of Birth.</li>
<li>Change the text property of the buttons to Next and Previous.</li>
<li>Double click on the form and within the form_load method type the code as shown below.</li>
<li>Double click on the Next button and within the <em>Click</em> type the code-<br />
<em>bs.MoveNext()</em></li>
<li>Double click on the previous button and within the <em>Click</em> event type the code-<br />
<em>bs.MovePrevious()</em></li>
</ol>
<p> </p>
<pre class="vb.net" name="code">
Public Class Form3
    Dim cn As New Odbc.OdbcConnection("Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=mydb; User=root;Password=;")
    Dim cmd As New Odbc.OdbcCommand
    Dim adp As Odbc.OdbcDataAdapter
    Dim ds As New DataSet
    Dim bs As BindingSource

    Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        cn.Open()
        cmd.Connection = cn
        cmd.CommandText = "Select * from mytable"
        adp = New Odbc.OdbcDataAdapter(cmd)
        adp.Fill(ds, "mytable")
        'Binding Statements Follow
        bs = New BindingSource(ds, "mytable")
        'Bind the name field to first textbox, type of data as text
        Me.TextBox1.DataBindings.Add("text", bs, "name")
        Me.TextBox2.DataBindings.Add("text", bs, "city")
        Me.TextBox3.DataBindings.Add("text", bs, "dob")

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        bs.MoveNext()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        bs.MovePrevious()
    End Sub
End Class</pre>
<p> </p>
<p>In the above code:</p>
<ol>
<li>The name,city and the dob (Date of Birth) columns of the table named <em>&#8216;mytable&#8217;</em> (this is the same table I used in an earlier post) is bound to three textboxes namely textbox1,textbox2 and textbox3 respectively using statement- <em> Me.TextBox1.DataBindings.Add(&#8221;text&#8221;, bs, &#8220;name&#8221;)</em> and so on.</li>
<li><em>bs.MoveNext()</em> binds the next record in the table to the controls (as long as a &#8216;next&#8217; exists).</li>
<li><em>bs.MovePrevious()</em> binds the previous record in the table to the controls (as long as a &#8216;previous&#8217; exists).</li>
</ol>
<script>var dzone_style="2";</script><script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script><p><a href="http://sharethis.com/item?&wp=2.5.1&amp;publisher=64f9dad7-a01a-431a-be35-77c065f806c3&amp;title=Binding+Data+To+Controls&amp;url=http%3A%2F%2Fdotnet.tekyt.info%2F%3Fp%3D29">ShareThis</a></p>]]></content:encoded>
			<wfw:commentRss>http://dotnet.tekyt.info/?feed=rss2&amp;p=29</wfw:commentRss>
		</item>
	</channel>
</rss>
<br />
<b>Warning</b>:  stristr() [<a href='function.stristr'>function.stristr</a>]: Empty delimiter in <b>/home/tekyt17/public_html/dotnet/wp-content/plugins/wassup/wassup.php</b> on line <b>2093</b><br />
