Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
MySql Help
#4
If you are trying to make something similar to a register you can try out the code i use

Code:
Private Sub MySqlRegister(ByVal username As String, ByVal password As String)
        Try
            MySqlConnection = New MySqlConnection
            MySqlConnection.ConnectionString = "server=" & Host & ";Port=" & Port & ";User id=" & User & ";Password=" & Pass & ";database=" & Database
            MySqlConnection.Open()
            Dim MySqlAdapter As New MySqlDataAdapter
            Dim SqlQuery = "SELECT * FROM testing WHERE username='" & username & "'"
            Dim Command As New MySqlCommand
            Dim MyData As MySqlDataReader
            Dim RegisterFinal As New MySqlDataAdapter

            Command.Connection = MySqlConnection
            Command.CommandText = SqlQuery
            MySqlAdapter.SelectCommand = Command
            MyData = Command.ExecuteReader

            If MyData.HasRows = 0 Then

                MySqlConnection.Close()
                MySqlConnection.Open()

                SqlQuery = "INSERT INTO testing (username, password) VALUE('" & username & "','" & password & "')"
                Command.Connection = MySqlConnection
                Command.CommandText = SqlQuery
                RegisterFinal.SelectCommand = Command
                MyData = Command.ExecuteReader

                ''send register success notice
                Send("responseR||Registered!||", Server.clientSocket)
                Log(username & " has been registered!", txt_log)

                MySqlConnection.Close()
                MyData.Close()
            Else
                ''send failed notice
                Send("responseR||There was an error in registration||", Server.clientSocket)
                Log(username & " Username is allready in use!", txt_log)
                MySqlConnection.Close()
                MyData.Close()
            End If
            MySqlConnection.Close()
            MyData.Close()
        Catch ex As Exception
            Log(ex.Message, txt_log)
        End Try
    End Sub

You shouldnt need to use a While Data.Read() in the code
Website: <!-- m --><a class="postlink" href="http://www.PBAProductions.com">http://www.PBAProductions.com</a><!-- m -->
E-Mail: <!-- e --><a href="mailtoTongueatrick@AriSystems.Org">Patrick@AriSystems.Org</a><!-- e -->
Skype: Qwaxer
Youtube: Qwaxer
[Image: 2hnx8av.jpg]


Messages In This Thread
MySql Help - by Blackrobot - 04-05-2012, 02:35 AM
Re: MySql Help - by brandonio21_phpbb3_import2 - 04-05-2012, 12:06 PM
Re: MySql Help - by Blackrobot - 04-06-2012, 03:43 AM
Re: MySql Help - by xolara - 04-06-2012, 03:49 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How can I read a link from mysql databse??? mnxford 9 32,852 04-12-2013, 06:27 PM
Last Post: brandonio21
  How do I use Listview to delete MySQL DB records kismetgerald 10 33,756 11-28-2012, 05:19 PM
Last Post: brandonio21
  [SOLVED] MySQL Update Query - What am I doing wrong? kismetgerald 11 43,011 10-18-2012, 07:16 PM
Last Post: brandonio21
  How do I fill my form with MySQL data based on Combobox? kismetgerald 8 26,576 10-14-2012, 09:05 PM
Last Post: brandonio21
  Help with creating an INSERT statement using MySQL kismetgerald 4 16,695 08-30-2012, 03:03 PM
Last Post: brandonio21
  MySQL Database Issue Moldraxian 7 28,948 08-13-2012, 08:58 PM
Last Post: brandonio21
  MySql Database Queries in VB.Net Moldraxian 6 22,250 07-26-2012, 03:44 PM
Last Post: Moldraxian
  How to Package MySql Connector and MySql Program? Moldraxian 3 14,702 07-20-2012, 12:23 PM
Last Post: brandonio21
  VB and MySQL help please Chad1020 2 12,191 03-21-2012, 04:10 PM
Last Post: brandonio21
  MySQL Help -Kid- 6 25,242 02-20-2012, 11:57 AM
Last Post: brandonio21

Forum Jump:


Users browsing this thread: 1 Guest(s)