从dart,odbc中获取sql语句的结果

时间:2014-07-24 09:27:25

标签: html odbc dart

我希望简单的问题,但我无法在互联网上找到答案,或者我仍然不明白该怎么做。

我想执行sql语句而不是获取结果并插入到我的表中,但我找不到与jdcb中相同的函数。

我找到了一些例子,但仍然不知道该怎么做。

代码:

  static void RegisterTable()
  {
    var hStmt = new SqlHandle();

    sqlAllocHandle(SQL_HANDLE_STMT, MyConnect, hStmt);

    sqlPrepare(hStmt, "SELECT R.[ID],U.[NAME],C.[CAR_NAME],R.[DESTINATION],R.[START_DATE],R.[END_DATE],R.[STATUS] FROM CAR_BOOKING.Registr_car R JOIN CAR_BOOKING.CARS C ON R.Car_id = C.id JOIN CAR_BOOKING.Users_table U ON U.id = R.user_id WHERE R.STATUS !=2;", SQL_NTS);

    // Bind result set columns.
    var id = new SqlIntBuffer();
    var name = new SqlStringBuffer(70);
    var carname = new SqlStringBuffer(70);
    var destination = new SqlStringBuffer(70);
    var startdate = new SqlDateBuffer(70);
    var enddate = new SqlDateBuffer();
    var status = new SqlIntBuffer(70);

    sqlBindCol(hStmt, 1, id.ctype(), id.address(), id.length(),null);
    sqlBindCol(hStmt, 2, name.ctype(), name.address(), name.length(),null);
    sqlBindCol(hStmt, 3, carname.ctype(), carname.address(), carname.length(),null);
    sqlBindCol(hStmt, 4, destination.ctype(), destination.address(), destination.length(),null);
    sqlBindCol(hStmt, 5, startdate.ctype(), startdate.address(), startdate.length(),null);
    sqlBindCol(hStmt, 6, enddate.ctype(), enddate.address(), enddate.length(),null);
    sqlBindCol(hStmt, 6, status.ctype(), status.address(), status.length(),null);

    sqlExecute(hStmt);

    List<Object> result = sqlFetch(hStmt);

    sqlFreeHandle(SQL_HANDLE_STMT, hStmt);
  }

如何将此结果发送到List之类的任何容器或打印成行?

0 个答案:

没有答案