代码采用C# .NET标准
var connectionString = $"<connection string here>";
var connection = new DB2Connection(connectionString);
connection.Open();
IDbCommand command = connection.CreateCommand();
string sqlStatement = "<a valid query goes here>";
command.CommandText = sqlStatement;
IDataReader dataReader = command.ExecuteReader();
var data = new DataTable();
data = dataReader.GetSchemaTable(); //This throws a NotSupportedException.
//data.Load(dataReader); //This should work, but the above line is what throws the exception, which is what this method is calling internally.在未注释掉的最后一行抛出NotSupportedException,并显示消息“指定的方法不受支持”。
我安装了IBM.Data.DB2.Core版本1.2.2.100,以及版本11.1许可证。如果您需要更多的上下文,请让我知道。
提前谢谢。
发布于 2018-06-16 15:51:19
查询select dont have join,只有一个表。
我建议您使用我的使用IDB2对象的代码:
var connectionString = $"<connection string here>";
string sqlStatement = "<a valid query goes here>";
var connection = new DB2Connection(connectionString);
DB2Command myCommand = new DB2Command(sqlStatement,connection);
connection.Open();
try
{
DB2DataReader reader = myCommand.ExecuteReader(CommandBehavior.KeyInfo);
DataTable dt = reader.GetSchemaTable();
reader.Close();
}
finally
{
connection .Close();
}https://stackoverflow.com/questions/50865937
复制相似问题