1

使用 .NET 连接器: http: //dev.mysql.com/doc/refman/5.1/en/connector-net-ref.html

MySQL中的一个字段设置为:

decimal(6) zerofill not null

如何在 VB 中检测到“zerofill”标志?

4

1 回答 1

1

您可以使用 获取列信息SHOW COLUMNS IN tablename,此查询以以下形式返回:

field         type                          null   key   default    extra
fieldname     int(10) unsigned zerofill      no            0    

因此,如果 int 中返回的字符串包含“zerofill”字符串,则要获得标志 zerofill,您必须查看类型:

像这样的东西可以解决问题:

static void Main(string[] args)
{
    dim conn as MySqlConnection
    conn = new MySqlConnection
    conn.ConnectionString = "Server = yourserver; Database = yourdb; Uid = youruser;Pwd = yourpassword;"

    conn.Open

    MySqlCommand cmd = new MySqlCommand
    cmd.Connection = conn
    cmd.CommandText = "SHOW COLUMNS IN yourtable"
    cmd.CommandType = CommandType.Text

    dim reader as MySqlDataReader
    reader = cmd.ExecuteReader

    while reader.Read
        Console.WriteLine("Field:{0}, zerofill:{1}",reader("field"),if(reader("type").ToString().Contains("zerofill"),true,false))
    end while
    conn.Close()
}
于 2011-07-27T06:01:59.310 回答