有没有办法SqlConnection
从 a中获取SqlDataAdapter
?
我曾期望找到一处SqlDataAdapter.Connection
房产。
有没有办法SqlConnection
从 a中获取SqlDataAdapter
?
我曾期望找到一处SqlDataAdapter.Connection
房产。
查看SelectCommand
您感兴趣的命令或任何命令。
您可以从相关的 SqlCommand 中获取。
根据设置的哪一个:
adapter.SelectCommand.Connection;
adapter.InsertCommand.Connection;
adapter.UpdateCommand.Connection;
adapter.DeleteCommand.Connection;
SqlDataAdapter
有属性SelectCommand
(类型SqlCommand
)和SelectCommand
有属性Connection
(类型SqlConnection
)。
用这个:
var da = new SqlDataAdapter();
....
string connectionString = da.SelectCommand.Connection.ConnectionString