Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in while (!dbHasCompleted(res)) { : argument is of length zero #31

Open
jfontestad opened this issue Oct 24, 2017 · 4 comments
Open

Comments

@jfontestad
Copy link

jfontestad commented Oct 24, 2017

dbHasCompleted(res)
Error in clrNew("rsqlserver.net.SqlDataHelper", res) : 
  Type:    System.InvalidOperationException
Message: Invalid attempt to call FieldCount when reader is closed.
Method:  Int32 get_FieldCount()
Stack trace:
   at System.Data.SqlClient.SqlDataReader.get_FieldCount()
   at rsqlserver.net.SqlDataHelper..ctor(SqlDataReader reader) in C:\Users\Ruaridh Williamson\Documents\GitHub\rsqlserver\src.nocompile\rsqlserver.net\src\SqlDataHelper.cs:line 68
@agstudy
Copy link
Owner

agstudy commented Oct 25, 2017

Ho w do you use it ? can you give more context ?
From the error message you are trying to access a closed reader, that means that the connection object is closed.

can you test this code for example:

  conn <- get_connection()
 dbWriteTable(con, "T_MTCARS", mtcars[1:5, ])
  query <- "SELECT  *       FROM    T_MTCARS"
  res <- dbSendQuery(conn, query)
  df1 <- fetch(res,as.integer(floor(nrow(mtcars)/2)))
  dbHasCompleted(res)

@jfontestad
Copy link
Author

Hello,
I was just using the default example that is attached with the DBI package.

res <- dbSendQuery(con, "SELECT * FROM mtcars WHERE cyl = 4")
while(!dbHasCompleted(res)){
chunk <- dbFetch(res, n = 5)
print(nrow(chunk))
}

@agstudy
Copy link
Owner

agstudy commented Oct 25, 2017

What is con?

@jfontestad
Copy link
Author

that's what i was using at the time as my connection variable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants