Parameterised Queries using ADO.NET throw exception unless non-parameterised query is run successful
I've created a gist with example code here: https://gist.github.com/NeilRobbins/10024191
We have replicated this using the 6.1.2 and 6.1.3 Vertica.Data dll.
Our cluster is running 6.1.3
The behaviour that we are seeing is that if we execute parameterised commands we get the following exception:
We execute a command first which is not parameterised (both select statements and Set Search_Path work for this).
Is this a known issue with the 6.1.3 Vertica.Data.dll?
Is there something we can do in terms of settings to fix this?
Help appreciated!
Neil
We have replicated this using the 6.1.2 and 6.1.3 Vertica.Data dll.
Our cluster is running 6.1.3
The behaviour that we are seeing is that if we execute parameterised commands we get the following exception:
System.NullReferenceException was unhandled HResult=-2147467261Unless...
Message=Object reference not set to an instance of an object.
Source=Vertica.Data
StackTrace:
at Vertica.Data.Internal.ADO.Net.SParameter.SetupNewTypeMetadata(Int32 newProviderType, Boolean isSigned, Boolean throwOnFailure)
at Vertica.Data.Internal.ADO.Net.SParameter.set_DbType(DbType value)
at Vertica.Data.VerticaClient.VerticaParameter.set_Type(VerticaType value)
at Vertica.Data.VerticaClient.VerticaParameter..ctor(String name, VerticaType type, Object value)
at Vertica.Data.VerticaClient.VerticaParameter..ctor(String name, VerticaType type)
at VerticaPlay.SimpleQuery.Run(String connectionString) in c:\git\spikes\VerticaPlay\VerticaPlay\Program.cs:line 32
at VerticaPlay.Program.Main(String[] args) in c:\git\spikes\VerticaPlay\VerticaPlay\Program.cs:line 15
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
We execute a command first which is not parameterised (both select statements and Set Search_Path work for this).
Is this a known issue with the 6.1.3 Vertica.Data.dll?
Is there something we can do in terms of settings to fix this?
Help appreciated!
Neil
0
Comments
This was an issue in the 6.x driver: "attempts to create a parameter before the first connection attempt in an ADO.NET application throws a NullReferenceException." The issue is resolved in the 7.x driver.
The workaround for 6.x, as you have discovered, is to call Open() on the connection before creating any parameters.
https://gist.github.com/NeilRobbins/11396515
(will cross-post to other thread also)