Search code examples
.netvb.netpostgresqliisnpgsql

inserting images on bytea column


i am using (i am obligated to use) npgsql driver to insert images on bytea column in postgresql db using vb.net code.

after inserting the first one successfully, i try to insert the second one it finished that i have inserted the first one again, it continues until i have reset the iis.

any ideas on how to deal this issue.

Dim cnnstr As String
        cnnstr = System.Configuration.ConfigurationManager.ConnectionStrings.Item("DMS_ConnectionString").ConnectionString

        Dim conn As NpgsqlConnection = New NpgsqlConnection(cnnstr)
        conn.Open()

        Dim command As NpgsqlCommand = New NpgsqlCommand("UPDATE ""FILES"" SET ""CONTENT""= :content WHERE ""ID""={0};", conn)
        Dim param As NpgsqlParameter = New NpgsqlParameter(":content", NpgsqlDbType.Bytea)

        param.Value = content

        command.Parameters.Add(param)
        command.ExecuteNonQuery()

        conn.Close()

thanks in advance.


Solution

  • All i have to do was to clear the paramaters.

    Me.myCommand.Parameters.Clear()
    

    Thanx, anyway!