gridview problems in VS Beta1

M

mspiezio

I'm trying to update or delete records using a gridview, but every time I try
(either on my own or copy from an example) , I get the error:
System.Data.SqlClient.SqlException: Must declare the scalar variable '@uid'.

my datasource commands are:
gridViewDataSource.SelectCommand = "SELECT [uid], [firstName], [lastName],
FROM [TestNames]";
gridViewDataSource.DeleteCommand = "DELETE FROM [TestNames] WHERE [uid] =
@uid";
gridViewDataSource.UpdateCommand = "UPDATE [TestNames] Set [firstName] =
@firstName, [lastName] = @lastName WHERE [uid] = @uid";

The update and delete commands do work if I leave off the WHERE statement,
but obviously that doesn't give me the desired result. If it try it with the
WHERE statement, I get the error.
 
M

mspiezio

I also tried changing the update command to add the 'original_' prefix, but
that didn't work.

gridViewDataSource.UpdateCommand = "UPDATE [TestNames] Set [firstName] =
@firstName, [lastName] = @lastName WHERE [uid] = @original_uid";
 

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

Members online

Forum statistics

Threads
474,141
Messages
2,570,817
Members
47,367
Latest member
mahdiharooniir

Latest Threads

Top