CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2009
    Posts
    9

    Getting DataTypeName of each column of table

    Hi there ,
    I have this code :


    Dim query As String = "show columns from " & table_name & " from " & db_name

    Dim connection As New MySqlConnection(cons)
    Dim cmd As New MySqlCommand(query, connection)

    connection.Open()

    Dim reader As MySqlDataReader
    reader = cmd.ExecuteReader()
    MessageBox.Show(reader.FieldCount)

    For i As Integer = 0 To reader.FieldCount - 1
    MessageBox.Show(reader.GetDataTypeName(5))
    Next

    I want to show the field's type of each column of the table , the problem is that FieldCount is incorrect , I do have fields more than VB.NET shows me.

    any solutions ?

    thanks.

  2. #2
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: Getting DataTypeName of each column of table

    That is a very odd looking query, I would expect that to crash.

    Select * from TableName

    Would select all of the columns
    Always use [code][/code] tags when posting code.

  3. #3
    Join Date
    Oct 2009
    Posts
    9

    Re: Getting DataTypeName of each column of table

    mysql> select * from teachers;
    Empty set (0.00 sec)

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured