2011-10-29 19 views
0

私は、vb.netコードを使用してpostgresql dbのbyteaカラムに画像を挿入するためにnpgsqlドライバを使用しています(私は義務付けています)。bytesaカラムに画像を挿入する

最初のものを挿入した後、2番目のものを挿入しようとしました。最初のものをもう一度挿入しました。iisをリセットするまで続きます。

この問題の対処方法については、

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() 

ありがとうございます。

答えて

1

私がしなければならないことは、パラマターをクリアすることでした。

Me.myCommand.Parameters.Clear() 

とにかく!