AnonymousJones Posted March 27, 2008 Posted March 27, 2008 First off, I'm not a database guy. My background is in C/C++ and I'm just getting the hang of this C# stuff. With that being said I'm setting up a DataGridView with a SqlDataSource that connects to an Oracle database. I have my select statement working, but the update statement either updates every row in the table when I don't include a WHERE clause or it won't update any rows at all. To give you an overview of what I'm trying to do, I want to edit comments in a table and have everything else remain the same. There are 5 or 6 fields that make the row unique and I try to add these to my WHERE clause but it causes nothing to get updated. I also try to use just one of the values from the table in my WHERE clause and that doesn't work either. The weird thing is that in "Query Builder" it will update the database. I can see the changes when I fire up the asp.net page, but then can't make updates to it while its running! Please help. I want to be able to update just one row with a comment and save it back to the database without the entire database table being updated. Here's the update statement: UpdateCommand="UPDATE PROJECT_EOC SET COMMENTS = :COMMENTS, UPDATED_BY = :UPDATED_BY, UPDATE_DATE = :UPDATE_DATE WHERE (TO_CHAR(BEGIN_YEAR) = :BEGIN_YEAR)"> <UpdateParameters> <asp:Parameter Name="COMMENTS" /> <asp:Parameter Name="UPDATED_BY" /> <asp:Parameter Name="UPDATE_DATE" /> <asp:Parameter Name="BEGIN_YEAR" /> everything works fine in QueryBuilder, but does not work when I run the application. Quote
Administrators PlausiblyDamp Posted March 27, 2008 Administrators Posted March 27, 2008 If it works without a where clause then I would suspect there is a problem with the WHERE (TO_CHAR(BEGIN_YEAR) = :BEGIN_YEAR) part. What does the TO_CHAR(BEGIN_YEAR) evaluate to? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
AnonymousJones Posted March 28, 2008 Author Posted March 28, 2008 That expression evaluates to the number "2006". Quote
Administrators PlausiblyDamp Posted March 30, 2008 Administrators Posted March 30, 2008 If you try calling the same statement through code do you get any errors generated? What data type is :BEGIN_YEAR defined as? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.