我想知道如何从数据库 sql 中获取单元格中的值? 例子 表名:登录 列:
Name | Birthday
Ina 19
string name = "Select Name from login";
string connection= "connection string path";
SqlConnection connect = new SqlConnection(connection);
SqlCommand command = new sqlCommand(name,connect);
string get = command;
但我确定这是错误的:(
我想知道如何获取值?
谢谢,
最佳答案
string get = command.ExecuteScalar().ToString();
您可能还需要注意从命令返回 null 的可能性。
关于c# - 登录 - 如何将数据库单元格中的值转换为字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9605507/