Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Sep 21st, 2008, 4:08 PM   #1
sunion
Newbie
 
Join Date: Apr 2008
Posts: 11
Rep Power: 0 sunion is on a distinguished road
Vb 2008 read/write from database mysql

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
sunion is offline   Reply With Quote
Old Sep 22nd, 2008, 8:44 AM   #2
sunion
Newbie
 
Join Date: Apr 2008
Posts: 11
Rep Power: 0 sunion is on a distinguished road
Re: Vb 2008 read/write from database mysql

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)
sunion is offline   Reply With Quote
Old Sep 22nd, 2008, 10:13 AM   #3
BeejCyr
Newbie
 
Join Date: Sep 2008
Posts: 1
Rep Power: 0 BeejCyr is on a distinguished road
Re: Vb 2008 read/write from database mysql

Personally for small queries I like to use the command object as well as the data reader. Here is a brief example only using the command object
        Dim cmd As New MySqlCommand
        Dim obj As New Object

        cmd.Connection = localMySqlConnection
        cmd.CommandText = "Select Count(acc) FROM accounts WHERE acc = textbox1.text"
        obj = cmd.ExecuteScalar
        If obj Is Nothing Then
            ' no match found
        Else
            ' match found
        End If
BeejCyr is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Working with VB6 and MySQL database Logical1 Visual Basic 5 Jul 21st, 2008 9:55 AM
VB 2002 -> VB 2008 conversion pal Visual Basic .NET 1 Sep 15th, 2007 4:43 AM
mysql database search programmingnoob Other Scripting Languages 6 Jun 27th, 2007 6:55 PM
critical: pls help: MySql Database with ASP.NET and C# paulchwd ASP.NET 1 Apr 16th, 2007 4:51 AM
mySQL: Changing unique database to fulltext BAS1X PHP 2 Oct 24th, 2005 10:14 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 8:15 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC