Howdy, Stranger!

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

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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)

[code]
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=*****;")
Try
localMySqlConnection.Open()
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")
localMySqlConnection.Close()
End Try
End Sub
End Class
[/code]

Comments

  • 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
    myadapter.Fill(dtset)
    myadapter.Dispose()

    Dim table As DataTable = dtset.Tables(0)
    [/code]
  • 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: brad_wang_cn@hotmail.com
    Skype: brad_wang[/b][/size][/color]
Sign In or Register to comment.