Jelajahi Sumber

Keep bindings until after execution.

Brucey 3 tahun lalu
induk
melakukan
9c4ebb3741
3 mengubah file dengan 11 tambahan dan 7 penghapusan
  1. 0 1
      odbc.mod/common.bmx
  2. 10 6
      odbc.mod/odbc.bmx
  3. 1 0
      odbc.mod/source.bmx

+ 0 - 1
odbc.mod/common.bmx

@@ -37,7 +37,6 @@ Import "-lodbc32"
 ?
 
 Import brl.blitz
-Import "odbchelper.c"
 
 Const SQL_AM_CONNECTION:Int = 1
 Const SQL_AM_NONE:Int = 0

+ 10 - 6
odbc.mod/odbc.bmx

@@ -575,12 +575,14 @@ Type TODBCResultSet Extends TQueryResultSet
 
 		' BIND stuff
 		Local values:TDBType[] = boundValues
+		Local strings:Byte Ptr[]
+		Local paramCount:Int
 
 		If values Then
-			Local paramCount:Int = bindCount
+			paramCount = bindCount
 
 			Local isNull:Int[] = New Int[paramCount]
-			Local strings:Byte Ptr[] = New Byte Ptr[paramCount]
+			strings = New Byte Ptr[paramCount]
 			
 			For Local i:Int = 0 Until paramCount
 
@@ -701,18 +703,20 @@ Type TODBCResultSet Extends TQueryResultSet
 
 			Next
 			
+		End If
+		
+		' execute the query
+		result = bmx_odbc_executePrepared(stmtHandle)
+
+		If strings Then
 			' free up the strings
 			For Local i:Int = 0 Until paramCount
 				If strings[i] Then
 					MemFree(strings[i])
 				End If
 			Next
-			
 		End If
 		
-		' execute the query
-		result = bmx_odbc_executePrepared(stmtHandle)
-		
 		If isSQLError(result) Then
 			TDBODBC(conn).processError(SQL_HANDLE_STMT, "Error executing statement", TDatabaseError.ERROR_STATEMENT, stmtHandle)
 			Return False

+ 1 - 0
odbc.mod/source.bmx

@@ -158,3 +158,4 @@ Import "iodbc/iodbc/prepare.c"
 Import "iodbc/iodbc/result.c"
 Import "iodbc/iodbc/odbc3.c"
 
+Import "odbchelper.c"