+ Post New Thread
Results 1 to 2 of 2
Coding Thread, Connecting to a MySQL server using Visual Studio 2010 and VB.Net in Coding and Web Development; I have just started to create a new program to help with my helpdesk, i want all the data from ...
  1. #1
    thesk8rjesus's Avatar
    Join Date
    Sep 2008
    Posts
    107
    Thank Post
    11
    Thanked 6 Times in 6 Posts
    Rep Power
    14

    Exclamation Connecting to a MySQL server using Visual Studio 2010 and VB.Net

    I have just started to create a new program to help with my helpdesk, i want all the data from my table to be displayed on the form. i have the following coding already but it displays nothing in my DataGridView:

    Imports System.Data
    Imports System.Data.Odbc


    Public Class Form1

    Private Sub conn()

    'Variables for ServerName, UserName & PassWord
    Dim SQLServerName As String = "ServerName"
    Dim SQLUserName As String = "UserName"
    Dim SQLPassWord As String = "PassWord"

    Try
    'Variable for the connection string
    Dim connectionString As String = "Driver={MySQL ODBC 3.51 Driver};Server=" & SQLServerName & ";Database=ictsupport;User=" & SQLUserName & "; Password=" & SQLPassWord & ";Option=3;"

    'Instialising the connection string
    Dim conn As New OdbcConnection(connectionString)

    'Opening the connection
    conn.Open()

    'Creating query to pull data from table
    Dim DataAdapter As New OdbcDataAdapter("SELECT ID FROM TableName", conn)

    'Putting data into DataGridView
    Dim DatSet As DataSet = New DataSet
    DataAdapter.Fill(DatSet)
    DataGridView1.DataSource = DatSet

    Catch SQLError As Exception
    MessageBox.Show("Error connecting to MySQL server " & SQLError.Message)
    End Try

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    conn()

    End Sub

    End Class


    but everytime i run the program it gives me an empty datagrid, if anyone has any idea on how to get the data in my form that would be great.

  2. #2

    ZeroHour's Avatar
    Join Date
    Dec 2005
    Location
    Edinburgh, Scotland
    Posts
    5,670
    Thank Post
    904
    Thanked 1,318 Times in 800 Posts
    Blog Entries
    1
    Rep Power
    445
    tbh I used this: MySQLDriverCS | Download MySQLDriverCS software for free at SourceForge.net to do mysql connects and it works excellently for my app.
    The only thing to note is that running hte app from a share will crash unless you sign the dll with your own CA issued cert and tweak .net frameworks settings but if you drop it to the local drive all will be fine.

SHARE:
+ Post New Thread

Similar Threads

  1. Visual Studio 2010 - SCCM
    By Duke in forum Windows
    Replies: 16
    Last Post: 7th August 2012, 09:40 AM
  2. Replies: 0
    Last Post: 13th April 2010, 05:01 PM
  3. Visual Studio 2008
    By SSFC in forum How do you do....it?
    Replies: 9
    Last Post: 26th January 2009, 07:54 AM
  4. Visual Studio 8 problem
    By walker01642 in forum Windows
    Replies: 1
    Last Post: 21st January 2009, 01:28 PM
  5. Visual Studio 2008
    By tango in forum Windows
    Replies: 1
    Last Post: 21st September 2008, 09:31 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •