Error While Deleteing Row From Database Using ExecuteNonQuery

G

Guest

I want to delete a row in database using SQL delete statement, with
parameters and Executenonquery capturing the return to confirm the number of
rows deleted. I code this in a standard way such as "Delete From Clients
Where ClientID = @ClientID And FName = @OldFname...." The paramters are
assigned in With statements like:
..Add("@ClientID", sqldbtype.int)

..Parameters("@ClientID").value = client.clientID

The error I keep getting is that the variable name @ClientID must be unique...

I don't know if it matters but ClientID is the primary key for this table.

I have tried some variations including just listing the ClientID field in
the SQL Statment. While this in fact deleted the row in the database,
Executenonquery returned a 0 showing no rows changed.

Any suggestions or tips would be appreciated.
 
G

Guest

First of all since ClientID is the primary key field, you dont have to pass
other paramenters.
Second, I'd like to check again, you said that the row was deleted
successfully but the rowchanged status was 0?
R. Thomas
 
G

Guest

R. Thomas – thanks for the response.

Actually, I was incorrect on the status. Its returning a –1 yet deleting
the row. I tried a statement with just the field for clientID (the primary
key) and the same result, -1 and row deleted. I built a statement using the
wizard on the data adapter and same result. I am totally stumped on this
one. I am at the point of creating a new project just to see if I can get
the dam code to work. All my update statements work fine, although I don’t
use a return from ExecuteNonQuery. In the delete statement I want to capture
the return value and assign it to the function which I have declared as a
Boolean. I don’t know why this would matter but this is a 3 tier application.
The client object gets passed from the GUI tier to the Data tier which is
where this problem occurs. Any thoughts would be appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top