<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: The VB.NET-MySQL Tutorial &#8211; Part 6</title>
	<atom:link href="http://www.vbmysql.com/articles/vbnet-mysql-tutorials/the-vbnet-mysql-tutorial-part-6/feed" rel="self" type="application/rss+xml" />
	<link>http://www.vbmysql.com</link>
	<description>Just another WordPress site</description>
	<lastBuildDate>Fri, 07 Jan 2011 12:23:44 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: rayda</title>
		<link>http://www.vbmysql.com/articles/vbnet-mysql-tutorials/the-vbnet-mysql-tutorial-part-6#comment-813</link>
		<dc:creator>rayda</dc:creator>
		<pubDate>Wed, 09 Jun 2010 02:30:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.vbmysql.com/articles/vbnet-mysql-tutorials/the-vbnet-mysql-tutorial-part-6/#comment-813</guid>
		<description>hello there. thanks for the great tutorial ^^
however, i have encounter with an error, or more suitable to say it as warning.
This was my complete Update code:
Private Sub cmdUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdUpdate.Click
        Dim conn As New MySqlConnection
        Dim mycommand As New MySqlCommand
        Dim myMessage As clsMessage

        conn.ConnectionString = myConnString

        mycommand.Connection = conn

        If cboMessage.SelectedIndex  -1 Then
            myMessage = CType(cboMessage.SelectedItem, clsMessage)
        Else
            mycommand.CommandText = &quot;Insert Into status(user_id, message,deleted) Values(?userID, ?message, &#039;False&#039;);&quot; _
                &amp; &quot;Select Last_Insert_ID()&quot;
            mycommand.Parameters.AddWithValue(&quot;?userID&quot;, myUserID)
            mycommand.Parameters.AddWithValue(&quot;?message&quot;, cboMessage.Text)


            Try
                conn.Open()
                myMessage = New clsMessage(mycommand.ExecuteScalar(), cboMessage.Text)
                cboMessage.Items.Insert(1, myMessage)
                cboMessage.SelectedIndex = 1
                conn.Close()
            Catch myerror As MySqlException
                MsgBox(&quot;There was an error updating the database:&quot; &amp; myerror.Message)
            End Try
        End If

        mycommand.CommandText = &quot;Insert into event(user_id, message_id, timestamp, status,creator)&quot; _
            &amp; &quot;Values(?UserID, ?MessageID, NOW(), ?Status, ?Creator)&quot;
        mycommand.Parameters.AddWithValue(&quot;?UserID&quot;, myUserID)


        If myMessage.ID = -1 Then
            mycommand.Parameters.AddWithValue(&quot;?MessageID&quot;, DBNull.Value)
        Else
            mycommand.Parameters.AddWithValue(&quot;?MessageID&quot;, myMessage.ID)
        End If
        mycommand.Parameters.AddWithValue(&quot;?Status&quot;, cboStatus.SelectedItem)
        mycommand.Parameters.AddWithValue(&quot;?Creator&quot;, myUserID)

        Try
            conn.Open()
            mycommand.ExecuteNonQuery()
        Catch myerror As MySqlException
            MsgBox(&quot;There was an error updating the database:&quot; &amp; myerror.Message)
        End Try
        refreshStatus(dgvStatus)
    End Sub

For the code  &quot;If myMessage.ID = -1 Then&quot;, there is a blue line under the word myMessage.ID.
The warning said that: Variable &#039;myMessage&#039; is used before it has been assigned a value. A null reference exception could result at runtime.

i am using visual studio2010 to do this.

does anyone can tell me what go wrong actually?
thanks</description>
		<content:encoded><![CDATA[<p>hello there. thanks for the great tutorial ^^<br />
however, i have encounter with an error, or more suitable to say it as warning.<br />
This was my complete Update code:<br />
Private Sub cmdUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdUpdate.Click<br />
        Dim conn As New MySqlConnection<br />
        Dim mycommand As New MySqlCommand<br />
        Dim myMessage As clsMessage</p>
<p>        conn.ConnectionString = myConnString</p>
<p>        mycommand.Connection = conn</p>
<p>        If cboMessage.SelectedIndex  -1 Then<br />
            myMessage = CType(cboMessage.SelectedItem, clsMessage)<br />
        Else<br />
            mycommand.CommandText = &#8220;Insert Into status(user_id, message,deleted) Values(?userID, ?message, &#8216;False&#8217;);&#8221; _<br />
                &amp; &#8220;Select Last_Insert_ID()&#8221;<br />
            mycommand.Parameters.AddWithValue(&#8220;?userID&#8221;, myUserID)<br />
            mycommand.Parameters.AddWithValue(&#8220;?message&#8221;, cboMessage.Text)</p>
<p>            Try<br />
                conn.Open()<br />
                myMessage = New clsMessage(mycommand.ExecuteScalar(), cboMessage.Text)<br />
                cboMessage.Items.Insert(1, myMessage)<br />
                cboMessage.SelectedIndex = 1<br />
                conn.Close()<br />
            Catch myerror As MySqlException<br />
                MsgBox(&#8220;There was an error updating the database:&#8221; &amp; myerror.Message)<br />
            End Try<br />
        End If</p>
<p>        mycommand.CommandText = &#8220;Insert into event(user_id, message_id, timestamp, status,creator)&#8221; _<br />
            &amp; &#8220;Values(?UserID, ?MessageID, NOW(), ?Status, ?Creator)&#8221;<br />
        mycommand.Parameters.AddWithValue(&#8220;?UserID&#8221;, myUserID)</p>
<p>        If myMessage.ID = -1 Then<br />
            mycommand.Parameters.AddWithValue(&#8220;?MessageID&#8221;, DBNull.Value)<br />
        Else<br />
            mycommand.Parameters.AddWithValue(&#8220;?MessageID&#8221;, myMessage.ID)<br />
        End If<br />
        mycommand.Parameters.AddWithValue(&#8220;?Status&#8221;, cboStatus.SelectedItem)<br />
        mycommand.Parameters.AddWithValue(&#8220;?Creator&#8221;, myUserID)</p>
<p>        Try<br />
            conn.Open()<br />
            mycommand.ExecuteNonQuery()<br />
        Catch myerror As MySqlException<br />
            MsgBox(&#8220;There was an error updating the database:&#8221; &amp; myerror.Message)<br />
        End Try<br />
        refreshStatus(dgvStatus)<br />
    End Sub</p>
<p>For the code  &#8220;If myMessage.ID = -1 Then&#8221;, there is a blue line under the word myMessage.ID.<br />
The warning said that: Variable &#8216;myMessage&#8217; is used before it has been assigned a value. A null reference exception could result at runtime.</p>
<p>i am using visual studio2010 to do this.</p>
<p>does anyone can tell me what go wrong actually?<br />
thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Charlie Childs</title>
		<link>http://www.vbmysql.com/articles/vbnet-mysql-tutorials/the-vbnet-mysql-tutorial-part-6#comment-812</link>
		<dc:creator>Charlie Childs</dc:creator>
		<pubDate>Tue, 03 Nov 2009 23:07:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.vbmysql.com/articles/vbnet-mysql-tutorials/the-vbnet-mysql-tutorial-part-6/#comment-812</guid>
		<description>I had a crash problem with a duplicate parameter.  Because it is coded twice in the final cmdUpdate VB 2008 Express shows error and stops program running just  after a personally specified status message was added and I hit the update button .  The offending line was pointed out by VB express crash mode ( error message &quot;Parameter &#039;?UserID&#039; has already been defined.&quot;).   After a little trial and error I tried removing the &quot;?&quot; from the &quot;?UserID&quot; bit and all works perfectly -  apart from the same problem I have had since part 4 of this tutorial - that is that my insert event query is not producing a new row -- my rows are being over written with updated status (all explained in my entry at the end of part 4 if anyone can help) - any help with that would be grately appreciated.

This is the duplicate line of code which caused the form to refuse personally specified messages being updated:

Extract from &quot;the completed cmdUpdate_Click procedure&quot; at end of tutorial 4.


&lt;!--   HERE --&gt;&gt;&gt;    myCommand.Parameters.Add(&quot;?userID&quot;, myUserID)
                             myCommand.Parameters.Add(&quot;?message&quot;, cboMessage.Text)

                        Try
                                conn.Open()
                                myMessage = New clsMessage(myCommand.ExecuteScalar(), cboMessage.Text)
                                cboMessage.Items.Insert(1, myMessage)
                               cboMessage.SelectedIndex = 1
                                conn.Close()
                        Catch myerror As MySqlException
                                MsgBox(&quot;There was an error updating the database: &quot; &amp; myerror.Message)
                        End Try
                End If

                myCommand.CommandText = &quot;INSERT INTO event(user_id, message_id, timestamp, status, creator)&quot; _
                 &amp; &quot;VALUES(?UserID, ?MessageID, NOW(), ?Status, ?Creator)&quot;

  &lt;!--  AND HERE --&gt;&gt;&gt;   myCommand.Parameters.Add(&quot;?UserID&quot;, myUserID)

The only difference between the above and my code is the &quot;Add&quot; becomes &quot;AddWithValue&quot; in VB 2008 Express

If anone can see how removing the &quot;?&quot; from &quot;?UserID&quot; may cause serious problems to the program down the line please let me and others who read this know. Thanks</description>
		<content:encoded><![CDATA[<p>I had a crash problem with a duplicate parameter.  Because it is coded twice in the final cmdUpdate VB 2008 Express shows error and stops program running just  after a personally specified status message was added and I hit the update button .  The offending line was pointed out by VB express crash mode ( error message &#8220;Parameter &#8216;?UserID&#8217; has already been defined.&#8221;).   After a little trial and error I tried removing the &#8220;?&#8221; from the &#8220;?UserID&#8221; bit and all works perfectly &#8211;  apart from the same problem I have had since part 4 of this tutorial &#8211; that is that my insert event query is not producing a new row &#8212; my rows are being over written with updated status (all explained in my entry at the end of part 4 if anyone can help) &#8211; any help with that would be grately appreciated.</p>
<p>This is the duplicate line of code which caused the form to refuse personally specified messages being updated:</p>
<p>Extract from &#8220;the completed cmdUpdate_Click procedure&#8221; at end of tutorial 4.</p>
<p><!--   HERE -->&gt;&gt;    myCommand.Parameters.Add(&#8220;?userID&#8221;, myUserID)<br />
                             myCommand.Parameters.Add(&#8220;?message&#8221;, cboMessage.Text)</p>
<p>                        Try<br />
                                conn.Open()<br />
                                myMessage = New clsMessage(myCommand.ExecuteScalar(), cboMessage.Text)<br />
                                cboMessage.Items.Insert(1, myMessage)<br />
                               cboMessage.SelectedIndex = 1<br />
                                conn.Close()<br />
                        Catch myerror As MySqlException<br />
                                MsgBox(&#8220;There was an error updating the database: &#8221; &amp; myerror.Message)<br />
                        End Try<br />
                End If</p>
<p>                myCommand.CommandText = &#8220;INSERT INTO event(user_id, message_id, timestamp, status, creator)&#8221; _<br />
                 &amp; &#8220;VALUES(?UserID, ?MessageID, NOW(), ?Status, ?Creator)&#8221;</p>
<p>  <!--  AND HERE -->&gt;&gt;   myCommand.Parameters.Add(&#8220;?UserID&#8221;, myUserID)</p>
<p>The only difference between the above and my code is the &#8220;Add&#8221; becomes &#8220;AddWithValue&#8221; in VB 2008 Express</p>
<p>If anone can see how removing the &#8220;?&#8221; from &#8220;?UserID&#8221; may cause serious problems to the program down the line please let me and others who read this know. Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Felix</title>
		<link>http://www.vbmysql.com/articles/vbnet-mysql-tutorials/the-vbnet-mysql-tutorial-part-6#comment-811</link>
		<dc:creator>Felix</dc:creator>
		<pubDate>Mon, 02 Nov 2009 08:56:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.vbmysql.com/articles/vbnet-mysql-tutorials/the-vbnet-mysql-tutorial-part-6/#comment-811</guid>
		<description>kann mir mal einer helfen bei meinem problem ich komme mit derm tutorial nicht so ganz klar.


und zwar habe ich folgendes problem: ich habe eine MySQL datenbank und möchte über VB.Net darauf zugreifen und bearbeiten aber es geht nicht ich bekomme keine verbindung zur datenbank. woran kann es liegen?</description>
		<content:encoded><![CDATA[<p>kann mir mal einer helfen bei meinem problem ich komme mit derm tutorial nicht so ganz klar.</p>
<p>und zwar habe ich folgendes problem: ich habe eine MySQL datenbank und möchte über VB.Net darauf zugreifen und bearbeiten aber es geht nicht ich bekomme keine verbindung zur datenbank. woran kann es liegen?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Website links : Saidul Islam &#171; ACM &#38; Project Euler :: Solved Problems</title>
		<link>http://www.vbmysql.com/articles/vbnet-mysql-tutorials/the-vbnet-mysql-tutorial-part-6#comment-810</link>
		<dc:creator>Website links : Saidul Islam &#171; ACM &#38; Project Euler :: Solved Problems</dc:creator>
		<pubDate>Tue, 02 Jun 2009 17:52:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.vbmysql.com/articles/vbnet-mysql-tutorials/the-vbnet-mysql-tutorial-part-6/#comment-810</guid>
		<description>[...] http://www.vbmysql.com/articles/vbnet-mysql-tutorials/the-vbnet-mysql-tutorial-part-6 [...]</description>
		<content:encoded><![CDATA[<p>[...] <a href="http://www.vbmysql.com/articles/vbnet-mysql-tutorials/the-vbnet-mysql-tutorial-part-6" rel="nofollow">http://www.vbmysql.com/articles/vbnet-mysql-tutorials/the-vbnet-mysql-tutorial-part-6</a> [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: c1y1k</title>
		<link>http://www.vbmysql.com/articles/vbnet-mysql-tutorials/the-vbnet-mysql-tutorial-part-6#comment-809</link>
		<dc:creator>c1y1k</dc:creator>
		<pubDate>Mon, 25 May 2009 04:57:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.vbmysql.com/articles/vbnet-mysql-tutorials/the-vbnet-mysql-tutorial-part-6/#comment-809</guid>
		<description>coba script ini:


 Public Function GetConnect()
        Dim conn As New MySqlConnection

        conn = New MySqlConnection(&quot;server=localhost;user id=root;password=ariek;database=kartu_puas&quot;)

        Return conn

    End Function

    Private conn As New MySqlConnection(&quot;server=localhost;user id=root;password=ariek;database=kartu_puas&quot;)

    Public MySqlComm As New MySql.Data.MySqlClient.MySqlCommand
    Public Sub PerintahSQL(ByVal S As String)

        MySqlComm = New MySql.Data.MySqlClient.MySqlCommand(S, conn)
        MySqlComm.CommandType = CommandType.Text
        MySqlComm.ExecuteNonQuery()
    End Sub

    Private Sub cbfakultas_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbfakultas.SelectedIndexChanged


        Dim s As String = &quot;SELECT * FROM jurusan where fakultas=&#039;&quot; &amp; Me.cbfakultas.Text &amp; &quot;&#039;&quot;
        If conn.State = ConnectionState.Closed Then
            conn = GetConnect()
            conn.Open()
        Else
            conn = GetConnect()
            conn.Close()
            conn.Open()
        End If

        PerintahSQL(s)
        Dim bb As MySql.Data.MySqlClient.MySqlDataReader = MySqlComm.ExecuteReader(CommandBehavior.CloseConnection)
        Me.cbjurusan.Items.Clear()
        Me.cbjurusan.Text = &quot;&quot;
        Do While bb.Read

            Me.cbjurusan.Items.Add(bb(&quot;jurusan&quot;))

        Loop
        conn = GetConnect()
        conn.Close()
    End Sub</description>
		<content:encoded><![CDATA[<p>coba script ini:</p>
<p> Public Function GetConnect()<br />
        Dim conn As New MySqlConnection</p>
<p>        conn = New MySqlConnection(&#8220;server=localhost;user id=root;password=ariek;database=kartu_puas&#8221;)</p>
<p>        Return conn</p>
<p>    End Function</p>
<p>    Private conn As New MySqlConnection(&#8220;server=localhost;user id=root;password=ariek;database=kartu_puas&#8221;)</p>
<p>    Public MySqlComm As New MySql.Data.MySqlClient.MySqlCommand<br />
    Public Sub PerintahSQL(ByVal S As String)</p>
<p>        MySqlComm = New MySql.Data.MySqlClient.MySqlCommand(S, conn)<br />
        MySqlComm.CommandType = CommandType.Text<br />
        MySqlComm.ExecuteNonQuery()<br />
    End Sub</p>
<p>    Private Sub cbfakultas_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbfakultas.SelectedIndexChanged</p>
<p>        Dim s As String = &#8220;SELECT * FROM jurusan where fakultas=&#8217;&#8221; &amp; Me.cbfakultas.Text &amp; &#8220;&#8216;&#8221;<br />
        If conn.State = ConnectionState.Closed Then<br />
            conn = GetConnect()<br />
            conn.Open()<br />
        Else<br />
            conn = GetConnect()<br />
            conn.Close()<br />
            conn.Open()<br />
        End If</p>
<p>        PerintahSQL(s)<br />
        Dim bb As MySql.Data.MySqlClient.MySqlDataReader = MySqlComm.ExecuteReader(CommandBehavior.CloseConnection)<br />
        Me.cbjurusan.Items.Clear()<br />
        Me.cbjurusan.Text = &#8220;&#8221;<br />
        Do While bb.Read</p>
<p>            Me.cbjurusan.Items.Add(bb(&#8220;jurusan&#8221;))</p>
<p>        Loop<br />
        conn = GetConnect()<br />
        conn.Close()<br />
    End Sub</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: andre</title>
		<link>http://www.vbmysql.com/articles/vbnet-mysql-tutorials/the-vbnet-mysql-tutorial-part-6#comment-808</link>
		<dc:creator>andre</dc:creator>
		<pubDate>Tue, 07 Apr 2009 10:43:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.vbmysql.com/articles/vbnet-mysql-tutorials/the-vbnet-mysql-tutorial-part-6/#comment-808</guid>
		<description>nevermind.... i still don&#039;t know why  i got the error but i downloaded the tutorial source and modified that and it works</description>
		<content:encoded><![CDATA[<p>nevermind&#8230;. i still don&#8217;t know why  i got the error but i downloaded the tutorial source and modified that and it works</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: andre</title>
		<link>http://www.vbmysql.com/articles/vbnet-mysql-tutorials/the-vbnet-mysql-tutorial-part-6#comment-807</link>
		<dc:creator>andre</dc:creator>
		<pubDate>Tue, 07 Apr 2009 10:23:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.vbmysql.com/articles/vbnet-mysql-tutorials/the-vbnet-mysql-tutorial-part-6/#comment-807</guid>
		<description>getting the same error as darin above when trying to select db fields... any ideas?

its basically ‘key cannot be null. Parameter name : key’.
thats the error and all the syntax is exactly the same as the tutorial except i changed the query which works when typed into sql browser</description>
		<content:encoded><![CDATA[<p>getting the same error as darin above when trying to select db fields&#8230; any ideas?</p>
<p>its basically ‘key cannot be null. Parameter name : key’.<br />
thats the error and all the syntax is exactly the same as the tutorial except i changed the query which works when typed into sql browser</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rachel Taylor</title>
		<link>http://www.vbmysql.com/articles/vbnet-mysql-tutorials/the-vbnet-mysql-tutorial-part-6#comment-806</link>
		<dc:creator>Rachel Taylor</dc:creator>
		<pubDate>Sat, 10 Jan 2009 21:13:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.vbmysql.com/articles/vbnet-mysql-tutorials/the-vbnet-mysql-tutorial-part-6/#comment-806</guid>
		<description>hi
30na1gb5crvydsvv
good luck</description>
		<content:encoded><![CDATA[<p>hi<br />
30na1gb5crvydsvv<br />
good luck</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marlin Ward</title>
		<link>http://www.vbmysql.com/articles/vbnet-mysql-tutorials/the-vbnet-mysql-tutorial-part-6#comment-805</link>
		<dc:creator>Marlin Ward</dc:creator>
		<pubDate>Fri, 09 Jan 2009 07:47:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.vbmysql.com/articles/vbnet-mysql-tutorials/the-vbnet-mysql-tutorial-part-6/#comment-805</guid>
		<description>hi
30na1gb5crvydsvv
good luck</description>
		<content:encoded><![CDATA[<p>hi<br />
30na1gb5crvydsvv<br />
good luck</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Fernando</title>
		<link>http://www.vbmysql.com/articles/vbnet-mysql-tutorials/the-vbnet-mysql-tutorial-part-6#comment-804</link>
		<dc:creator>Fernando</dc:creator>
		<pubDate>Mon, 01 Dec 2008 09:00:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.vbmysql.com/articles/vbnet-mysql-tutorials/the-vbnet-mysql-tutorial-part-6/#comment-804</guid>
		<description>to Anthony:

I have the same problem with .Focus() method and solve it changing to .Select() method.</description>
		<content:encoded><![CDATA[<p>to Anthony:</p>
<p>I have the same problem with .Focus() method and solve it changing to .Select() method.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

