Domaine : tutoriel
Tag : visual studio 2008 fr
Aller à l'accueil


TAGS SPECIALISES :

vb visual studio
visual c studio
visual studio tuto
visual c 2008
windows visual studio
visual studio c
visual studio 7
c visual studio
visual studio 2008 2010
update visual studio 2008
visual studio 2005 gratuit
visual studio windows
visual studio 2008 update
visual studio c#
visual basic studio 2008
net visual c
compilateur visual studio
visual studio 2008 express
visual basic 2008 express
visual studio c# net
visual studio 2009
visual studio c 2005
visual studio vb
visual studio 2005 c
c visual studio 2010
visual studio c 2010
visual studio net vb
vb.net visual studio
visual studio 2010 c
visual c studio 2005
visual c gratuit
visual studio vb.net
visual studio 2010 c#
c visual studio 2005
cours visual studio 2008
visual c 2010
visual studio 1
cours visual studio 2010
visual studio 2003
version visual studio 2008







Full Module Code:

Imports MySql.Data.MySqlClient
Module SQL 'Setup a new MySQLConnection Public Connection As New MySqlConnection 'Dim Command so we can execute sql commands Dim Command As MySqlCommand Public Sub ConnecttoDB() Try 'we are setting the username, password, ect Connection = New MySqlConnection(String.Format("server={0};user id={1}; password={2}; port=3306; database={3}; pooling=false", Login.txtServer.Text, Login.txtUser.Text, Login.txtPass.Text, Login.txtDB.Text)) 'okay now everything is set lets connect, if there is a problem is goes down to line 17 Connection.Open() Main.Show() Login.Close() Catch mysql As MySqlException 'displays whatever went wrong from Connection.Open() MsgBox(mysql.Message) Catch ex As Exception MsgBox(ex.Message) End Try End Sub Public Sub FillData(ByVal Table As String, ByRef Output As DataTable) Try 'Setting up a new command to grab all the data from the table the user inputs, limits the items to 100 so it doesnt laggg Command = New MySqlCommand("SELECT * FROM `" & Table & "` LIMIT 100;", Connection) 'this fills all the data that was inside the command that was executed, into MySqlA Dim MySqlA As New MySqlDataAdapter(Command) 'puts all the info from the database into the datatable Output MySqlA.Fill(Output) 'if the rows count = 0 then that means there is no data so set the datatable to = nothing If Output.Rows.Count = 0 Then Output = Nothing End If Catch e As MySqlException MsgBox(e.Message) End Try End Sub



GRAB BUTTON CODE Dim Output As New DataTable If txttable.Text = "" Then MsgBox("Select a table to get the data from") : Exit Sub End If view.DataSource = Nothing FillData(txttable.Text, Output) If Output Is Nothing Then MsgBox("No data") Else view.DataSource = Output End If



LOGIN BUTTON CODE

Public Class Login Private Sub btnConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConnect.Click ConnecttoDB() End Sub
End Class

code pour embarquer la vidéo : >>>    http://www.youtube.com/embed/2cszI04Gyew    <<<






TAGS GENERAUX :

  vnc tuto  tuto css  html tutoriel  tuto ipad  tuto imovie  tuto vnc  tuto pdf  html tuto  php tutoriel  tutoriel linux