thesk8rjesus Posted November 23, 2010 Posted November 23, 2010 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.
ZeroHour Posted November 23, 2010 Posted November 23, 2010 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.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now