I'm giving my first steps into HDBC using ODBC to connect to a local SQL Server.
After a quickQuery
on the connection, I can't close
it. I need to perform a commit
first.
Is this the way it is supposed to be? Why is the commit
necessary when I'm only performing a query?
On GHCi:
m + Database.HDBC Database.HDBC.ODBC
conn <- connectODBC "Driver={SQL Server};Server=thiagon\\sqlserver2012;Database=senior;UID=framework;PWD=framework;"
vals <- quickQuery conn "SELECT TOP 5 * FROM whatever;" []
print vals
commit conn
disconnect conn
If I remove the commit conn
line, I get an exception:
*** Exception: SqlError {seState = "[\"25000\"]", seNativeError = -1, seErrorMsg = "disconnect: [\"0: [Microsoft][ODBC SQL Server Driver]Estado de transa\\65533\\65533o inv\\65533lido\"]"}
The message is in portuguese, it means "invalid transaction state".