|
-
Jul 20th, 2011, 04:40 PM
#1
Thread Starter
New Member
Mysql without install?
ok, so i made a login for a program I wrote. The program was written in vb 2008 express edition. It uses a MySql connector to connect to a database and confirm the username and password.
Here's the source:
Code:
Imports System.Data.SqlClient
Imports MySql.Data.MySqlClient
Public Class Login
Dim mysqlconnection As MySqlConnection
Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
'Retrieves online database
TextBox1.Text = "Status: Verifiying"
mysqlconnection = New MySqlConnection
mysqlconnection.ConnectionString="server=db4free.net;Port=3306; user id=<username>; password=<password>; database=<database>"
mysqlconnection.Open()
Dim myadapter As New MySqlDataAdapter
Dim sqlquary = "SELECT * From Users WHERE Username='" & UsernameTextBox.Text & "' AND Password='" & PasswordTextBox.Text & "';"
Dim command As New MySqlCommand
command.Connection = mysqlconnection
command.CommandText = sqlquary
myadapter.SelectCommand = command
Dim mydata As MySqlDataReader
mydata = command.ExecuteReader
'Verification
If mydata.HasRows = 0 Then
MsgBox("Incorrect Login: Access Denied", MsgBoxStyle.Critical, "Access Denied")
UsernameTextBox.Text = ""
PasswordTextBox.Text = ""
TextBox1.Text = "Status: Failed"
Else
MsgBox("Successful Login: Access Granted", vbInformation, "Access Granted")
Form1.Show()
Me.Close()
End If
End Sub
Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click
Me.Close()
End Sub
Private Sub Passwordtextbox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles PasswordTextBox.KeyPress
'Prevents sql injection
If e.KeyChar = "=" Then
MsgBox("Error: sql Injection detected, shutting down.", MsgBoxStyle.Critical, "Hacker Detected!")
End
ElseIf e.KeyChar = "-" Then
MsgBox("Error: sql Injection detected, shutting down.", MsgBoxStyle.Critical, "Hacker Detected!")
End
ElseIf e.KeyChar = "'" Then
MsgBox("Error: sql Injection detected, shutting down.", MsgBoxStyle.Critical, "Hacker Detected!")
End
Else
End If
End Sub
End Class
Here's the problem, it works fine on mine, but whenever it's given to someone that doesn't have the mysql connector installed, it won't run correctly, and crashes. I've tried just updating the clients .net framework, but it simply won't work. Is there any way I can make my code so it will still be compatible with computers without the mysql connector? If not, then are there any alternative methods to achieving an online login(with a link please)?
>>Link<< to the connector
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|