Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

查询表结构语气ado.net 返回有点问题 #91

Open
XZL-Github opened this issue Nov 18, 2024 · 1 comment
Open

查询表结构语气ado.net 返回有点问题 #91

XZL-Github opened this issue Nov 18, 2024 · 1 comment

Comments

@XZL-Github
Copy link

image
image
上面代码输出的不是下面工具里面的这种结构

@huskar-t
Copy link
Collaborator

@XZL-Github Different print formats

                    connection.Open();
                    using (var command = new TDengineCommand(connection))
                    {
                        command.CommandText = "describe test.d1001;";
                        using (var reader = command.ExecuteReader())
                        {
                            var fieldCount = reader.FieldCount;
                            for (var i = 0; i < fieldCount; i++)
                            {
                                Console.Write($"{reader.GetName(i),-20}|");
                            }
                            Console.WriteLine();
                            for (var i = 0; i < fieldCount; i++)
                            {
                                Console.Write("--------------------+");
                            }
                            Console.WriteLine();
                            while (reader.Read())
                            {
                                for (int i = 0; i < fieldCount; i++)
                                {
                                    var v = reader.GetValue(i);
                                    switch (v)
                                    {
                                        case byte[] bs:
                                            Console.Write($"{System.Text.Encoding.UTF8.GetString(bs),-20}|");
                                            break;
                                        default:
                                            Console.Write($"{v,-20}|");
                                            break;
                                    }
                                }
                                Console.WriteLine();
                            }
                        }
                    }

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants