Login and Register Form (MYSQL)
Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
10 posts
Page 1 of 1
Free MYSQL Server: http://www.db4free.net
MYSQL Connector download: http://www.mysql.com/downloads/connector/net/
And import the MYSQL Connector.
Go to Project-->Add Reference...---->.NET tab--->Click MySql.Data--->OK
OK to import the MySql.Data.
-Table: user
- Fields: username, password, email
MYSQL Connector download: http://www.mysql.com/downloads/connector/net/
And import the MYSQL Connector.
Go to Project-->Add Reference...---->.NET tab--->Click MySql.Data--->OK
OK to import the MySql.Data.
Code: Select all
Login Form
Imports MySql.Data.MySqlClient
Code: Select all
Register Form
Dim conn As MySqlConnection
'connect to DB
conn = New MySqlConnection()
conn.ConnectionString = "server=82.103.129.94; user id=dbusername; password=dbpassword; database=db"
'see if connection failed.
Try
conn.Open()
Catch myerror As MySqlException
MsgBox("Error connecting to database!")
End Try
'sql query
Dim myAdapter As New MySqlDataAdapter
Dim sqlquery = "SELECT * FROM user WHERE username='" + TextBox1.Text + "' AND password= '" + TextBox2.Text + "'"
Dim myCommand As New MySqlCommand()
myCommand.Connection = conn
myCommand.CommandText = sqlquery
'start query
myAdapter.SelectCommand = myCommand
Dim myData As MySqlDataReader
myData = myCommand.ExecuteReader()
'see if user exists
If myData.HasRows = 0 Then
MsgBox("Invalid username and/or password!")
Code: Select all
MYSQL table and field requirement:Dim conn As MySqlConnection
'connect to DB
conn = New MySqlConnection()
conn.ConnectionString = "server=82.103.129.94; user id=dbusername; password=dbpassword; database=db"
'see if connection failed.
Try
conn.Open()
Catch myerror As MySqlException
MsgBox("Error connecting to database!")
End Try
'sql query
Dim myAdapter As New MySqlDataAdapter
Dim sqlquery = "SELECT * FROM user WHERE username='" + TextBox1.Text + "'"
Dim myCommand As New MySqlCommand()
myCommand.Connection = conn
myCommand.CommandText = sqlquery
'start query
myAdapter.SelectCommand = myCommand
Dim myData As MySqlDataReader
myData = myCommand.ExecuteReader()
'see if user exists
If myData.HasRows = 0 Then
conn.Close()
conn.Open()
Dim registerfinal As New MySqlDataAdapter
sqlquery = "INSERT INTO user (username, password, email) VALUES ('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "')"
myCommand.Connection = conn
myCommand.CommandText = sqlquery
'start query
registerfinal.SelectCommand = myCommand
myData = myCommand.ExecuteReader
MsgBox("Thank you for registering!")
-Table: user
- Fields: username, password, email
You do not have the required permissions to view the files attached to this post.
doesn't work for me.
Nailing my feet to the floor is easier than using my own muscles to balance, but you don't see me doing that 

zachman61 wrote:doesn't work for me.Maybe you can be more specific ?
We shall let the revolution begin.. the revolution for freedom, freedom against censorship. We shall fight in the fields and in the streets, we shall fight in the hills; we shall never surrender
Spam Much? Please read the rules before writing useless posts...
I have made a Website on http://www.000webhost.com
And registered there a mysql,
but everytime i try to connect and save into my mysql database with this code i get a error.
Where do i get the Informations for server and user id ?!
i tryd using the website ip as server and my servername "server23.000webhost.com" and also the mysql servername ?!
And registered there a mysql,
but everytime i try to connect and save into my mysql database with this code i get a error.
Where do i get the Informations for server and user id ?!
i tryd using the website ip as server and my servername "server23.000webhost.com" and also the mysql servername ?!
Agust1337 wrote:Whats the error exception?I just made a Database on http://www.db4free.net
Everything works now.
000webhost doesn't have support for remote MySQL connections, that's why they fail.

10 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023