Page 2 of 2

Re: Tutorial - How to create a MySQL Login Application

Posted: Sun Feb 28, 2010 8:40 pm
by Scottie1972
marve25 wrote:
can you make a tut on how to setup the MySQL, got a lot of errors on it
Yes, It is very easy.
There is only a few things that need to be done other then installing MySQL to your computer.

1.Install MySQL 5.x.x
2.Open the Port: 3306 in your Firewall - Sometimes you have to do this because the install software doesnt.

If you are wanting other people from the Internet to connect and use your MySQL server then you need to
PortForward or IP Passthought, your external IP to your MySQL server.
(Dont ask me, Because I DO NOT know your modem type or ISP information)
This is also known as your WAN Address and a function your are configuring is called DMZ Mode.
So the DMZ needs to point to your computer.

After you have done this, Re-BOOT your computer so it can change to its new IP Address.

Now, serch for my.cnf (c:\Program Fles\MySQL\...my.cnf) find the line that says:
bind-address = 127.0.0.1
change this to
bind-address = 0.0.0.0

Save my.cnf close your editor.

open a CMD Prompt type: mysql /restart

This will restart the mysql server with its new settings.

NOTE
IF you do not want to allow internat connections to you mysql sever, (Which can be very dangerous if allowed)
Then just install MySQL Server and set the Username and Password for the root User.

Thats it.

To find your ip address:
Open a CMD Prompt: type ipconfig /all HIT ENTER
Look for a line that says IP Address: ###.###.###.###
This will be the IP Address that the MySQL Server will be listening to for connections.

I hope this helps. ON a scale to
1 - being easy
10 - being a nightmare

I give this a 4 or 5 because of having to configure your modem.



Enjoy;

Scottie

Re: Tutorial - How to create a MySQL Login Application

Posted: Tue Mar 02, 2010 7:02 pm
by marve25
i found the problem, bind-adress 127.0.0.1 doesnt exist to me and MySQL using local network to me

Re: Tutorial - How to create a MySQL Login Application

Posted: Tue Mar 30, 2010 1:30 am
by NoWayIn
It also wont work if your host doesn't allow Remote MySQL connections

Re: Tutorial - How to create a MySQL Login Application

Posted: Thu Apr 01, 2010 3:12 am
by dan2130
Hi, i have a question about how can i list result from a table by example i have modified that tutorial and what i want to do its to get messages.
here its my table structure : and i want to list all result containing the username in the reciever )

Table structure of messages
- ID
(little 5 letters to identify the message for deleting)
- Expeditor
(The expeditor name)
- Reciever
(the reciever name and what i want to list the result)
- Message
(the message goes here)
- Sending date
(the date the message are sent)

can you help me to resolve this i'm stucked at this step
thanks

Re: Tutorial - How to create a MySQL Login Application

Posted: Thu Apr 01, 2010 5:00 am
by Scottie1972
dan2130 wrote:
Hi, i have a question about how can i list result from a table by example i have modified that tutorial and what i want to do its to get messages.
here its my table structure : and i want to list all result containing the username in the reciever )

Table structure of messages
- ID
(little 5 letters to identify the message for deleting)
- Expeditor
(The expeditor name)
- Reciever
(the reciever name and what i want to list the result)
- Message
(the message goes here)
- Sending date
(the date the message are sent)

can you help me to resolve this i'm stucked at this step
thanks

Table structure of messages
- ID
- Expeditor
- Reciever
- Message
- Sending date

OK we are using the "reader()" method to retreive data from the database.
From you table above the read() will look like this
Code: Select all
reader.getstring(0) 'ID
reader.getstring(1) 'Expeditor
reader.getstring(2) 'Reciever
reader.getstring(3) 'Message
reader.getstring(4) 'Sending date
All this does is asign a value for each column in your database table.
So if ID is the first coloumn in your table then, the first reader()
will be reader.getstring(0)

To do a loop
Code: Select all
While reader.Read()
reader.getstring(0)
End While
Select all data from database by username.
Code: Select all
Try
            Dim query As String = "SELECT * FROM users WHERE username='" + txtUsername.Text + "';"
            Dim connection As New MySqlConnection(connStr)
            Dim cmd As New MySqlCommand(query, connection)
            connection.Open()
            Dim reader As MySqlDataReader
            reader = cmd.ExecuteReader()
            reader.Read()
            If reader.HasRows = True Then
                
		reader.getstring(0) 'ID
		reader.getstring(1) 'Expeditor
		reader.getstring(2) 'Reciever
		reader.getstring(3) 'Message
		reader.getstring(4) 'Sending date

		MsgBox("You have messages!")
                
            Else
                
                MsgBox("Sorry! You have no messages!")
                
            End If
            reader.Close()
            connection.Close()
        Catch ex As Exception
            Console.WriteLine(ex.Message)
        End Try
I hope this helps. But this is the best way of retreiving data from a mysql database in a vb 2008 application.

Scottie1972

Re: Tutorial - How to create a MySQL Login Application

Posted: Thu Apr 01, 2010 11:52 am
by dan2130
and can i list that results in a listbox becose the reciever can get more than 1 message