This is a migrated thread and some comments may be shown as answers.

Grid Update Failing

2 Answers 108 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Nick
Top achievements
Rank 1
Nick asked on 18 Aug 2008, 08:38 PM
I'm working on a pretty simple project, but I've run into some trouble and so I hope someone can help!  I have a combo box and a grid sharing a single page.

The combo box is populated with names from a SQL database.  On changing, the combo box does an auto-postback and populates the grid with a few rows from a table called "Housing" based on the value of the Combo Box.

The combo box selection and subsequent population of the grid actually works very smoothly.

The problem I'm having is when I try to use the "update" function in the grid.  When I try to update, I receive an error that says "Incorrect syntax near 'nvarchar'.  *line break* Must declare the scalar variable '@housing_id'".  (I have a feeling that it is actually two different errors).

Now the strange part to me is that I can get the update function to work by putting in a new grid that is not affected by the combo box (it displays all of the "Housing" items, not just those specific to one user).  I use the same exact insert/select/update/delete functions.... so I'm terribly confused as to why it doesn't work when I put the combo box into the equation.

Thanks for any help!

2 Answers, 1 is accepted

Sort by
0
Konstantin Petkov
Telerik team
answered on 21 Aug 2008, 08:17 AM
Hi Nick,

Were you able to resolve the error?

Unfortunately I suppose the error does nothing with the combobox, but is a general SQL one. You can probably replace the combobox with a dropdownlist and get the same error.

Actually this is widely discussed on the web. See this thread for example.

I hope this helps!

All the best,
Konstantin Petkov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Nick
Top achievements
Rank 1
answered on 21 Aug 2008, 11:23 AM
Yes, I was able to figure it out.

I kept searching high and low for an example that resembled what I was doing, but couldn't seem to find one. 

The problem was actually with my Update command in the DataSource associated with the RadGrid.   I just had to make a minor change to that code and it worked.

Thanks,

Nick
Tags
Grid
Asked by
Nick
Top achievements
Rank 1
Answers by
Konstantin Petkov
Telerik team
Nick
Top achievements
Rank 1
Share this question
or