Vb 2008 read/write from database mysql - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Vb 2008 read/write from database mysql

sunionsunion Posts: 5Member
hello the code down here works perfectly to connect to a mysql server.
but now i want it to read from it.
so it can look that , lets say textbox2.text and textbox3.text are the same as in the database he will get acces to my program.
and if its not the same then he wont get acces.

Well i hope someone can help me , if u want me to be more specific just say it.

(I am using vb 2008)

Imports MySql.Data.MySqlClient
Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim localMySqlConnection As MySqlConnection = New MySqlConnection("server=*********;database=dbforprog;uid=******;password=*****;")
If localMySqlConnection.State = ConnectionState.Open Then
MessageBox.Show("Verbinding tot stand gebracht", "Let op!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1)
End If
Catch err As MySqlException
MessageBox.Show(err.Message, "Error")
End Try
End Sub
End Class


  • sunionsunion Posts: 5Member
    So i added this code
    Textbox1.text <- There should the account be typed in
    textbox2.text <- there should the password be typed in
    now i want it to see if textbox2.text(the password) is the same as in the database for textbox1.text(the account)

    i know it should be done with a query but i dont know how to use it so any help should be welcome.

    thx allot.

    [code] Dim myadapter As New MySqlDataAdapter("Select * FROM accounts WHERE accounts.acc = textbox1.text", localMySqlConnection)
    Dim dtset As New DataSet

    Dim table As DataTable = dtset.Tables(0)
  • bradwangbradwang Posts: 197Member
    Yeah, you may use DataTable or DataReader to read the password value out and compare to what the user has entered in the password field and then judge if the user has the correct credential or not.

    I think you can just use Google for a search of such DataReader related articles and I'm sure you could find tons of information. :)

    [color=Green][size=1][b]Brad Wang - .NET Freelancer from China
    MSN: [email protected]
    Skype: brad_wang[/b][/size][/color]
Sign In or Register to comment.