Solved

How to get MySQL host info by using VB.NET ?

Posted on 2004-04-26
11
245 Views
Last Modified: 2010-04-24

I connect to MySQL, using MyODBC, it seem to be good.

How can I get MySQL host info by using VB.NET ?
I want to fill MySQL host info into a combobox in which user can choose their suitable MySQL host for connection (when my form MySQLLogin is loaded).

Addition: and how to get database name ?

Thanks so much
0
Comment
Question by:tipt
  • 5
  • 4
11 Comments
 
LVL 27

Expert Comment

by:planocz
ID: 10917900
Hi tipt,

Iam not sure on getting to the host info, but here is some code that you might be able to use in working with the table names.

Imports System.Data.SqlClient

 '**** Server Connection Vars *********
    Public sDBServer As String
    Public sUSERid As String
    Public sDBName As String
    Public sDBPass As String
    Public Connect As SqlConnection

     '********* database Var's ************
    Public sSql As String
    Public sTableName As String
    Public sTables() As String                'For Table Listing
    Public bFirstTime As Boolean
    Public iCounter As Short

  Public Sub OpenDBSqlConnection()
        If Len(sDBPass) = 0 Then
            sDBPass = ""
        End If
        Try
            Connect = New SqlConnection("Initial Catalog=" & sDBName & ";Data Source=" & sDBServer & ";User ID=" & sUSERid & ";password=" & sDBPass & ";")
            Connect.Open()
            Connect.Close()
        Catch Ex As Exception
            MsgBox("Exception: " & Ex.Message & "  " & Ex.ToString, MsgBoxStyle.Critical)
            Cursor.Current = Cursors.Default
        End Try
    End Sub

  Public Sub TableNames()
        Dim i As Integer
        Dim DS As New DataSet
        sSql = ""
        sSql = "SELECT table_name FROM Information_Schema.Tables"
        Try
            Dim Adapter = New SqlDataAdapter(sSql, Connect)
            Dim sNames As String

            Adapter.Fill(DS)
            ReDim sTables(DS.Tables(0).Rows.Count - 1)
        bFirstTime = True
        iCounter = 0

            For i = 0 To DS.Tables(0).Rows.Count - 1
                sNames = (DS.Tables(0).Rows(i)).Item(0)
                Select Case Left(sNames, 3)
                    Case "sys"
                    Case UCase(Left(sNames, 3))
                    Case "tbl"
                        If bFirstTime = True Then
                            iFirstTime = i
                            bFirstTime = False
                        End If
                        sTables(i) = sNames
                        iCounter = i
                End Select
            Next
        Catch Exp As Exception
            MsgBox(Exp.Message & " in TableNames Procedure", MsgBoxStyle.Critical, "General Error")
        End Try
    End Sub
0
 

Author Comment

by:tipt
ID: 10919457
is it also suitable for MySQL ?
0
 
LVL 27

Accepted Solution

by:
planocz earned 250 total points
ID: 10919562
Yes; that is what Iam running. you can use OdbcConnection.
for example of Sybase.....

    Public SyConnect As Odbc.OdbcConnection
   
Public Sub OpenDBSyBaseConnection()
        Try
            SyConnect = New Odbc.OdbcConnection("DSN=MySybaseName;UID=dba;PWD=MyPassword")
            SyConnect.Open()
            SyConnect.Close()
        Catch Ex As Exception
            MsgBox("Exception: " & Ex.Message & "  " & Ex.ToString, MsgBoxStyle.Critical)
            Cursor.Current = Cursors.Default
        End Try
    End Sub

' in the above procedure
 Dim Adapter = New SqlDataAdapter(sSql, SyConnect)
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

Author Comment

by:tipt
ID: 10920105
let me check it :)
0
 

Author Comment

by:tipt
ID: 10924470
This way just for connection, i got it, thanks so much.
But I want to getting host info :(
0
 

Author Comment

by:tipt
ID: 10930848
noone help me?
0
 
LVL 27

Expert Comment

by:planocz
ID: 10931040
What kind of hosting are you wanting?
Web connection? Database connection?
0
 

Author Comment

by:tipt
ID: 10931060
database connection
0
 
LVL 27

Expert Comment

by:planocz
ID: 10931235
I have never needed to use Host info from server.
So what are you trying to do with this info?
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question