0

Below is my code for adding parameters in my vb .net code for prepared statements of npgsql.

Dim xConn As NpgsqlConnection = ConnectDB()
Dim xCmd As NpgsqlCommand = xConn.CreateCommand()

xCmd.CommandText = "UPDATE " & xTable & " SET previous_tot_adj = @prev_adj ,tot_adj = @tot_adj WHERE version = " & _version & " AND monthly_mq_id = @Index"

For Each Index In _Results.Keys

    If Not IsNothing(_Results.Item(Index)) Then

        xCmd.Parameters.AddWithValue("prev_adj", NpgsqlTypes.NpgsqlDbType.Double, _Results.Item(Index))
        xCmd.Parameters.AddWithValue("tot_adj", NpgsqlTypes.NpgsqlDbType.Double, _Results.Item(Index))
        xCmd.Parameters.AddWithValue("Index", NpgsqlTypes.NpgsqlDbType.Bigint, Index)

    End If

Next

xCmd.Prepare()
xCmd.ExecuteNonQuery()

After executing this code i get this kind of error .

A first chance exception of type 'Npgsql.NpgsqlException' occurred in Npgsql.dll
ERROR: 08P01: bind message has 34193 parameter formats but 1 parameters

Can anyone enlighten me for what's wrong on what I'm doing?

Thanks!

2
Contributors
2
Replies
26
Views
3 Weeks
Discussion Span
Last Post by rproffitt
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.