下面是我的代码,用于在我的vb .net代码中为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()
执行此代码后,出现这种错误:
Npgsql.dll中发生类型为'Npgsql.NpgsqlException'的第一次机会异常 错误:08P01:绑定消息具有34193个参数格式,但有1个参数
有人能启发我我在做什么吗?