|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
DataAdapter.Update not actually updating my databaseadded or modified in the datatable was indeed added or edited. The update methods return value IS 1, indicating that the row I was after was altered. And for the rest of the execution of the program, the datatable has the modified value. However, the DB does NOT get modified at all... As soon as I close and re-run the program the JobsDataTable reverts back to it's original state... it HAS to be something dumb, I am about to give up and write out a SQL statement... private void SaveChanges() { BackupDataDataSet.JobsDataTable jt = _Adapter.GetData(); object[] objArr = {_JobID, _txtName.Text, _txtDescription.Text, _txtExcludeList.Text, _txtSourceFolder.Text, _txtDestFolder.Text, _cbIncludeSubFolders.Checked, _cbCompressFiles.Checked }; jt.BeginLoadData(); jt.LoadDataRow(objArr, false); int junk = _Adapter.Update(jt); jt.EndLoadData(); jt.AcceptChanges(); _IsDirty = false; } If you want the complete application you can download the zip file (DB included) at: http://www.ats-engineers.com/filebackup.zip It's all in a project already, I am using MS VC# Express.... HELP * sobs uncontrollably * AB ** Insert Clever Signature Here ** ** UPDATE **
So I gave up and went in and used straight SQL Queries and now I am still having the exact same problem. I checked the file permissions on the MDB file that VC# Express created for me and all the read/write permissions are set correctly for the user that is running the program at the time (I even added that "everyone" has full access to the file), still have the same problem. Seems to be a bug with the fact that this DB file is not being hosted by the SQL Server service, and is instead setup through some other backend accessor to the DB file. Guess the next step is to host the DB file in my SQL Server Express SQL Server Service and see if I still have the same problem... Any input would be greatly appreciated! The new code is as follows... private void SaveChanges() { BackupDataDataSet.JobsDataTable jt = _Adapter.GetData(); object[] objArr = {_JobID, _txtName.Text, _txtDescription.Text, _txtExcludeList.Text, _txtSourceFolder.Text, _txtDestFolder.Text, _cbIncludeSubFolders.Checked, _cbCompressFiles.Checked }; SqlCommand command; if (_JobID ==-1) { string insert = "insert into jobs (name, description, excludefilelist, sourcefolder, destinationfolder, includesubfolders, compress) values " + "('" + _txtName.Text+ "','" +_txtDescription.Text+ "','" +_txtExcludeList.Text+ "','" +_txtSourceFolder.Text+ "','" + _txtDestFolder.Text+ "','" +_cbIncludeSubFolders.Checked+ "','" +_cbCompressFiles.Checked +"')"; command = new SqlCommand(insert, _Adapter.Connection); } else { string update = "update jobs set name='"+_txtName.Text+"', description='"+_txtDescription.Text+"', excludefilelist='"+_txtExcludeList.Text+"', sourcefolder='"+_txtSourceFolder.Text+"', " + "destinationfolder='"+_txtDestFolder.Text+"',includesubfolders='"+_cbIncludeSubFolders.Checked+"', compress='"+_cbCompressFiles.Checked+"' where id = " + _JobID; command = new SqlCommand(update, _Adapter.Connection); } command.Connection.Open(); command.ExecuteNonQuery(); _IsDirty = false; } ** Another update - Resolved **
It would seem that I was correct in my assumptions that the fact that the MDB file was not hosted under SQL Server's actual service was the problem. After attaching the MDB file to the DB Server the previous code worked (both versions) THAT was annoyying, I wonder if they are ever gonna fix that, I would like to avoid having users having to have a SQL Server running on their network for this app, but ohh well... AB |
|||||||||||||||||||||||