VB.NET

Moderators: seancampbell
Number of threads: 4020
Number of posts: 10026

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Vb 2008 read/write from database mysql Posted by sunion on 21 Sept 2008 at 1:16 PM
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=*****;")
		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

Report
Re: Vb 2008 read/write from database mysql Posted by sunion on 22 Sept 2008 at 5:42 AM
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.



        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)

Report
Re: Vb 2008 read/write from database mysql Posted by bradwang on 22 Sept 2008 at 11:07 PM
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. :)


Brad Wang - .NET Freelancer from China
MSN: brad_wang_cn@hotmail.com
Skype: brad_wang



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.