Obtain Column Description In VB.Net

  • I want to extract the "Description" property of a SQL 2000 column using VB.Net. I have used the following code to populate a list box with the "ColumnName" property. I instead want to populate the list box with the "Description" property. Can someone please help?

    <code>

    Private Sub GetFieldList()

    ' Create instance of connection object.

    Dim myConnection As New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))

    ' Create instance of dataset object, passing in SQL string

    Dim mySQL As String

    mySQL = "SELECT * FROM MyTable"

    Dim myAdapter As New SqlDataAdapter(mySQL, myConnection)

    Dim DS As DataSet = New DataSet()

    myAdapter.FillSchema(DS, SchemaType.Source)

    Dim i As Integer

    For i = 0 To DS.Tables(0).Columns.Count - 1

    lstAvail.Items.Add(New ListItem(i, DS.Tables(0).Columns(i).ColumnName))

    Next

    End Sub

    </code>

  • This was removed by the editor as SPAM

  • Answer to similar query exists in

    http://www.sqlservercentral.com/forum/link.asp?TOPIC_ID=11768

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply