error in the update

  • Thread starter Thread starter Jose
  • Start date Start date
J

Jose

Hello. I have this error when i was an update in a table. It's occurs when
modify but when is a new record update withouts problems.

"La generación SQL dinámica para UpdateCommand no es compatible con
SelectCommand, que no devuelve ninguna información sobre columnas clave."

Please how resolve this error

Thanks a lot.
 
Jose,

How did you create your update commands, there are three and insert, and
update and a delete.

Cor
 
No Cor. I create this line. But the updatecommand not
Dim cmdbuilder As New SqlCommandBuilder(da)

It's is the problem?
 
Jose,

Showing than the Select command will probably give us more an idea why you
get this error.
(Including filling of the parameters if you use those)

Normally this should not be there.

Cor
 
Dim sqlmodi As SqlCommand = New SqlCommand("Select uno, dos, tres, cuatro,"
& _

"cinco, seis, siete, ocho, nueve," & _

"diez, once, doce, trece, catorce, quince," & _

"dieciseis, diecisiete, dieciocho, diecinueve, veinte, veintiuno," & _

"veintidos, veintitres, veinticuatro, veiticinco, veintiseis," & _

"veintisiete, veintiocho, veintinueve from tabla where uno=" + "'" + cbuscar
+ "'" & _

" and dos=" + "'" + cbuscar2 + "'" & _

" and tres=" + "'" + cbuscar3 + "'" & _

" and cuatro=" + "'" + cbuscar5 + "'", cn)

da.SelectCommand = sqlmodi

da.Clear()

da.Fill(ds, "tabla")
 
In my table doesn't exists primary key. In my select return all the fields.
Any suggestions?
 
Jose,

The use of + as concatinator in VB.Net can lead to very strange results.

What it does when option strict on is not set, with this is

dim a as string = "10" + "20" give as result "30"

I cannot see if that can be the problem.

Cor
 
Well Cor the problem is the primary key of my table. i dont have primary
key. If i use a primary key solve the problem
 
You will have to drop the use of the CommandBuilder if you don't return a
column with unique values and specify the INSERT, UPDATE, and DELETE
commands manually.
 
Jose,

I am glad you found your solution. The primary key question was what
Carston had asked you when I wrote my reply, I had than seen Carstens
question but not yet your reply. Otherwise it had been obvious.

But my reply stays the same it is better to use & for continuation of
strings, while it is even better to use parameters for SQLStrings.

(But I had not the idea that not using parameters was causing the error)


Cor
 
Back
Top