c#无法将类型System.data.sqlclient.sqldatareader隐式转换为system.data.sqlclient.sqldatadapter

时间:2018-07-22 10:28:16

标签: c# sqldatareader sqldataadapter

说我无法将类型System.Data.SqlClient.SqlDataReader隐式转换为System.Data.SqlClient.SqlDataAdapter

It Says I Cannot implicitly convert type System.data.sqlclient.sqldatareader to system.data.sqlclient.sqldatadapter

3 个答案:

答案 0 :(得分:0)

您的编译器是正确的。

将行替换为:

con.Open();

var adapter = new SqlDataAdapter(cmd);

itms.Load(adapter);

答案 1 :(得分:0)

您实际上打算使用SqlDataReader而不是

SqlDataReader reader = cmd.ExecuteReader();

答案 2 :(得分:0)

您可以使用以下内容:

 @Override
public void start(Future<Void> startFuture) throws Exception {
    super.start(startFuture);

    System.out.println("Referencing event bus");
    // Reference to the event bus running on the JVM
    EventBus eventBus = vertx.eventBus();

    System.out.println("Creating HttpServer");
    // Create HTTP Server to handle incoming requests
    HttpServer httpServer = vertx.createHttpServer();

    System.out.println("Creating Router");
    // Create Router for routing to appropriate endpoint
    Router router = Router.router(vertx);

    System.out.println("Starting to consume message sent over event bus");
    // Consume the incoming message over the address PING
    eventBus.consumer("PING", event -> {
        System.out.println("Received message: " + event.body());
        event.reply("Received at PING address");

    });
    System.out.println("Receiver ready and receiving messages");

让我知道,如果有帮助的话:)