有没有办法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