[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now


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

Posted on 2004-04-26
Medium Priority
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
Question by:tipt
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
LVL 27

Expert Comment

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
            Connect = New SqlConnection("Initial Catalog=" & sDBName & ";Data Source=" & sDBServer & ";User ID=" & sUSERid & ";password=" & sDBPass & ";")
        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"
            Dim Adapter = New SqlDataAdapter(sSql, Connect)
            Dim sNames As String

            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
        Catch Exp As Exception
            MsgBox(Exp.Message & " in TableNames Procedure", MsgBoxStyle.Critical, "General Error")
        End Try
    End Sub

Author Comment

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

Accepted Solution

planocz earned 1000 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()
            SyConnect = New Odbc.OdbcConnection("DSN=MySybaseName;UID=dba;PWD=MyPassword")
        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)
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 10920105
let me check it :)

Author Comment

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

Author Comment

ID: 10930848
noone help me?
LVL 27

Expert Comment

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

Author Comment

ID: 10931060
database connection
LVL 27

Expert Comment

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

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
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 course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

656 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