GridView and SqlDataSource Woes
I'm new to ASP NET 2.0 and Visual Studio 2005. I'm setting up a page that pulls data from a SQL database. I'm using a custom SQL query in the data source because I want to perform some actions on the data before it is displayed in the gridview. I guess because of this I have to also supply my own Edit and Delete statements instead of selecting their nice check box in the advanced area. The problem I'm running in to is that when I run my page and click on the edit or delete links it acts like every thing is fine, but the data hasn't changed. Neither on the web page or in the db table itself. I don't know this for sure, but it seems like my T-SQL statement is solid except for the WHERE clause. I'm concerened that it isn't updating / deleting because I'm not referencing the row to be updated properly. Also, the data in the table doesn't have any single row that is unique so my primary key is actually two rows combined. Below are the SELECT, UPDATE, and DELETE statements I'm trying to use.
SELECT Statement (This works just fine, but here for reference)
SELECT [JobName], [CompState], [BackupType], [StartTime], DATEDIFF(n,'12/30/1899 00:00:00',[Queue]) AS Queue, DATEDIFF(n,'12/30/1899 00:00:00',[Duration]) AS Duration, [DataWritten], [CentComplete], [SessionID], [Error], [ReportCreator], [NumMedia], [NumErrors], [NumWar], [NumFiles], [ReportDate] FROM [tblReportData] WHERE MONTH([ReportDate]) = MONTH(GETDATE()) AND DAY([ReportDate]) = DAY(GETDATE()) AND YEAR([ReportDate]) = YEAR(GETDATE())
UPDATE Statement
UPDATE tblReportData SET JobName = @JobName, CompState = @CompState, BackupType = @BackupType, StartTime = @StartTime, Queue = @Queue, Duration = @Duration, DataWritten = @DataWritten, NumMedia = @NumMedia, NumErrors = @NumErrors, NumWar = @NumWar, NumFiles = @NumFiles, CentComplete = @CentComplete, SessionID = @SessionID, Error = @Error, ReportCreator = @ReportCreator, ReportDate = @ReportDate WHERE (JobName = @original_JobName) AND (ReportDate = MONTH(@original_ReportDate)) AND (ReportDate = DAY(@original_ReportDate)) AND (ReportDate = YEAR(@original_ReportDate))
DELETE Statement
DELETE FROM [tblReportData] WHERE [JobName] = @original_JobName AND MONTH([ReportDate]) = MONTH(@original_ReportDate) AND DAY([ReportDate]) = DAY(@original_ReportDate) AND YEAR([ReportDate]) = YEAR(@original_ReportDate)
Mike Jones
|