Guest

Jamie Brunton

By: a guest on Oct 5th, 2009  |  syntax: VB.NET  |  size: 1.14 KB  |  hits: 2,923  |  expires: Never
download  |  raw  |  embed  |  report abuse
Copied
  1. Imports MySql.Data.mysqlclient
  2.  
  3. Public Class Form1
  4.  
  5. Private Sub cmdsend_Click( ByVal sender As System.Object,  ByVal e As System.EventArgs) Handles cmdsend.Click
  6.         Dim conn As MySqlConnection
  7.         'connect to DB
  8.         conn = New MySqlConnection()
  9.         conn.ConnectionString = "server=192.168.1.50; user id=root; password=jamierocks; database=relog"
  10.         'see if connection failed.
  11.         Try
  12.             conn.Open()
  13.         Catch myerror As MySqlException
  14.             lblstatus.Text = "Error connecting to database"
  15.         End Try
  16.         'sql query
  17.         Dim myAdapter As New MySqlDataAdapter
  18.  
  19.         Dim sqlquery = Txtstring.text
  20.         Dim myCommand As New MySqlCommand()
  21.         myCommand.Connection = conn
  22.         myCommand.CommandText = sqlquery
  23.         'start query
  24.         myAdapter.SelectCommand = myCommand
  25.         Dim myData As MySqlDataReader
  26.         myData = myCommand.ExecuteReader()
  27.         'see if user exits.
  28.         If myData.HasRows = 0 Then
  29.             txtoutput.Text = "Invalid Authkey"
  30.         Else
  31.             txtoutput.Text = "Authentication Key accepted!"
  32.         End If
  33. End Sub
  34. End Class