I have a WCF windows service and that service is used to do the CURD operation over PostgreSQL. Now I am trying to pass dynamic parameters to insert or update statements in PostgreSQL.
I have built a string at the client end with the query and parameters and at the service end I am parsing that string for Query and parameter name, values.
Here is the string that I am sending from the client end:
Insert into Test_Images (ImageID,Image,Description) Values (@ImageID,@Image,@Description)*!*cf92d82b3fc6b53490df71a2e2989dfc*!*@ImageID*!*5*!*@Image*!*5646546546546546541621321654168514685141654564532168541*!*@Description*!*'Test'
Here is the code that I am using at the service end to pass these values to the database:
Private Sub InsertBlob()
'dbconn is the psqlconnection
procCmd.Connection = dbConn
If (paramValues IsNot Nothing And paramNames IsNot Nothing) Then
If (paramNames.Length <> paramValues.Length) Then
Dim sE As New Exception("Parameter Names count and Values count do not match")
sE.Data.Add("HTTPSTATUSCODE", 400)
Throw sE
End If
For pCount = 0 To paramNames.Length - 1
procCmd.Parameters.AddWithValue(paramNames(pCount), paramValues(pCount))
Next
End If
dbConn.Open()
procCmd.CommandText = sQuery
procCmd.ExecuteNonQuery()
End Sub
This method is giving up the pervasive error.
Pervasive.Data.SqlClient.Lna.k: [LNA][PSQL][SQL Engine]Error in expression: @ImageID
While the query below without parameters always executes correctly.
Insert into Test_Images (ImageID,Image,Description) Values (2,5646546546546546541621321654168514685141654564532168541,'Test')
Could someone please help me with inserted these values as parameters. And also I would need help in passing the BLOB data for the Image field.
Note: The data for the Image field is a LONGVARBINARY type, as I cannot insert the total BLOB array here I have inserted a small binary string just for understanding. I am using BLOB array as I cannot send the path for the image as the client and server will not be on the same machine.