Friday, February 24, 2012

Array Problem

Hi All,

I have this code below:
Dim a As Integer = 0
While a <= myArray.Length()
Conn.Open()
Dim UpdateCmd As New SqlClient.SqlCommand("Update email_addr SET category = 'Deleted' where HP = @.hp", Conn)
UpdateCmd.Parameters.Add("@.hp", SqlDbType.VarChar, 50).Value = myArray(a)
UpdateCmd.ExecuteNonQuery()
a = a + 1
Conn.Close()
End While

BUt, When I run it, I receive error "Prepared statement '(@.hp varchar(50))Update email_addr SET category = 'Deleted' wher' expects parameter @.hp, which was not supplied. "

DOes anyone have the solution?

Thanks...

You are performing update in a LOOP ?

why not this :

update email_addr

set category = 'Deleted'

where HP in ('1', '2', '3', '4') -- array value here

No comments:

Post a Comment