Mysql 选择具有NOTNULL属性的列

Mysql 选择具有NOTNULL属性的列,mysql,vb.net,Mysql,Vb.net,我正在寻找一种方法来选择具有NOTNULL属性的列并将其存储到ArrayList中。 我已经找了很多线索来寻找答案,但没有运气 我创建了一个函数,它允许我从表中读取数据,但问题是我不知道如何让它读取具有NOTNULL属性的列名。这是我试过的代码 Public Function getNull(ByVal table As String) As ArrayList Dim col_names As String = New String(getNames(table)) Dim n

我正在寻找一种方法来选择具有NOTNULL属性的列并将其存储到ArrayList中。 我已经找了很多线索来寻找答案,但没有运气

我创建了一个函数,它允许我从表中读取数据,但问题是我不知道如何让它读取具有NOTNULL属性的列名。这是我试过的代码

Public Function getNull(ByVal table As String) As ArrayList
    Dim col_names As String = New String(getNames(table))
    Dim nullColumns As ArrayList = New ArrayList
    Dim dtreader As MySqlDataReader
    Dim conn As MySqlConnection
    Dim strConn As String
    strConn = withDatabase
    conn = New MySqlConnection(strConn)
    Try
        Dim cmd = New MySqlCommand("SELECT * FROM " & table & " WHERE " & col_names & " IS NOT NULL", conn)
        conn.Open()
        dtreader = cmd.ExecuteReader()
        While dtreader.Read
           'Get column names with not null property'

        End While
    Catch ex As Exception
        MsgBox("Error " + ex.ToString, MsgBoxStyle.Critical)
    End Try
    Return nullColumns
End Function




Public Function getNames(ByVal table As String) As String
    Dim conn As MySqlConnection
    Dim strConn As String
    Dim names As New String("")
    strConn = withDatabase
    conn = New MySqlConnection(strConn)
    Using conn
        conn.Open()
        Dim dt = conn.GetSchema("Columns", New String() {Nothing, Nothing, table})
        For Each row In dt.Rows
            names += row("COLUMN_NAME") + " AND "
        Next
        names = names.Remove(names.Length - 4)

    End Using
    conn.Close()
    Return names
End Function

我发现的其他线程是在列中查找空值,这不是我要查找的。

您编写“WHERE*is not null”-这总是正确的!您不能说
WHERE*
您必须指定类似
的列名,其中xxx不为NULL,yyy不为NULL