SWAT Not Recognizing Mgt2 Table (Cannot Edit Inputs)

421 views
Skip to first unread message

Amanda Snow

unread,
Dec 9, 2019, 4:10:28 PM12/9/19
to ArcSWAT

I think there may be a glitch in SWAT that is preventing us from editing the management operations.  We were given a set of inputs from another group as the model standard and it runs successfully with those inputs.  However, every time we edit it through the SWAT interface, it deletes the mgt2 table and the model doesn’t run.  If we edit the actual mgt2 table in Access, SWAT does not run the model with the changed data, only the original input standard data.

Is there any way to get help with this?  We’ve spent a couple of weeks trying to get around it.

Jim Almendinger

unread,
Dec 9, 2019, 6:45:32 PM12/9/19
to Amanda Snow, ArcSWAT
I haven't heard of ArcSWAT deleting the mgt2 table before.  I don't have a suggestion for you. 

If you modify the mgt2 table in Access, you must tell ArcSWAT to re-write the mgt files (= the text files in txtinout folder) before running SWAT to make these changes take effect.  This is true for any project database table that you modify directly in Access.  SWAT only sees the text files in txtinout. 

Just a note of caution -- it's easy to ruin the mgt2 table and crash your model.  You can change some of the parameter values, but adding or deleting lines is deadly, unless you have really figured out how SWAT sequences these lines (I haven't).  So if I'm changing operations, I always use the interface (and make sure you save those changes, and/or extend them to other HRUs -- this can take some practice). 

And always, if you change mgt1 or mgt2, it's smart to keep original or "last known working" copies, so you can recover if you make mistakes and corrupt the tables. 

Good luck,
-- Jim


James E. Almendinger, PhD
Director, St. Croix Watershed Research Station
16910 152nd St N, Marine on St. Croix, MN  55047



On Mon, Dec 9, 2019 at 3:10 PM Amanda Snow <as...@mlj-llc.com> wrote:

I think there may be a glitch in SWAT that is preventing us from editing the management operations.  We were given a set of inputs from another group as the model standard and it runs successfully with those inputs.  However, every time we edit it through the SWAT interface, it deletes the mgt2 table and the model doesn’t run.  If we edit the actual mgt2 table in Access, SWAT does not run the model with the changed data, only the original input standard data.

Is there any way to get help with this?  We’ve spent a couple of weeks trying to get around it.


Confidentiality Notice: The information in this transmission (including any attachments) is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. If you are not the intended recipient, any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information is prohibited. The user of this information is NOT authorized to copy, attach, transmit, or include this information in any bid or proposal without the authors explicit authorization. If you have received this in error, please contact MLJ-LLC at (530) 756-5200 and destroy all copies of the original message.

--
You received this message because you are subscribed to the Google Groups "ArcSWAT" group.
To unsubscribe from this group and stop receiving emails from it, send an email to arcswat+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/arcswat/ce28db67-d9af-4a77-aabe-998b8f9397a0%40googlegroups.com.

Amanda Snow

unread,
Dec 10, 2019, 6:18:47 PM12/10/19
to ArcSWAT
Thank you for your response.

This might be a complicated scenario to describe.  
I need to change the harvest date for one landuse crop.  To do that, I go to Edit SWAT Input -> .Mgt table -> select a subbasin, land use, soil, and slope that has the landuse crop I'm interested in, go to the operations tab in the Edit Management Parameters window, and the schedule is there.  I then press "edit values," choose the harvest date to edit, press "edit operation," change the date, and press "ok."  From there, I can either save the schedule with a new name or just press "Save Edits."  Either way, it gives the error written below:
"Unhandled exception has occurred in a component in your application.  If you click Continue. the application will ignore this error and attempt to continue.  Cannot open database ". It may not be a database that your application recognizes, or the file may be corrupt."  Details box includes this:
************** Exception Text **************
System.Data.OleDb.OleDbException (0x80004005): Cannot open database ''.  It may not be a database that your application recognizes, or the file may be corrupt.
   at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr)
   at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
   at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
   at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
   at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
   at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
   at SWAT_InputFileEdit.frmMgtEdit.cmdSave_Click(Object sender, EventArgs e)
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)"

After clicking "Continue," if I click "Save Edits" again, it gives a similar error: 
"Unhandled exception has occurred in a component in your application.  If you click Continue. the application will ignore this error and attempt to continue.  ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver] Cannot open databse 'I'.  It may not be a database that your application recognizes, or the file may be corrupt."

After exiting out, when I try and go back into that database to edit, it gives an ArcSWAT error saying, "Cannot open database ". It may not be a database that your application recognizes, or the file may be corrupt."  Once that error is exited, another Edit Subbasin Inputs error window pops up saying, ""Unhandled exception has occurred in a component in your application.  If you click Continue. the application will ignore this error and attempt to continue.  The Microsoft Jet database engine cannot find the input table or query 'mgt2'.  Make sure it exists and that its name is spelled correctly."

If I click "Continue" from there, the operations tab is grey and blank where the operations previously had been.  Additionally, the Access database that previously held the mgt2 table now does not have the mgt2 table.

It's as if the mgt2 table is deleted any time it is opened (even to just view) through SWAT.


Any assistance is GREATLY appreciated.

Jim Almendinger

unread,
Dec 11, 2019, 10:25:47 AM12/11/19
to Amanda Snow, ArcSWAT
I haven't seen this behavior before, and all I can say it appears that something has been corrupted.  Can you make other modifications to cropping practices without crashing the model?  Or is it just this one?  You need to isolate the thing(s) that cause the crash.  Starting over at some point in the past when things ran fine may be your best bet. 
Sorry for the non-answer, and good luck.
-- Jim


James E. Almendinger, PhD
Director, St. Croix Watershed Research Station
16910 152nd St N, Marine on St. Croix, MN  55047


Confidentiality Notice: The information in this transmission (including any attachments) is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. If you are not the intended recipient, any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information is prohibited. The user of this information is NOT authorized to copy, attach, transmit, or include this information in any bid or proposal without the authors explicit authorization. If you have received this in error, please contact MLJ-LLC at (530) 756-5200 and destroy all copies of the original message.

--
You received this message because you are subscribed to the Google Groups "ArcSWAT" group.
To unsubscribe from this group and stop receiving emails from it, send an email to arcswat+u...@googlegroups.com.

Amanda Snow

unread,
Dec 11, 2019, 12:51:11 PM12/11/19
to ArcSWAT
We were given the set of files and the model runs fine but the database cannot be edited.  I will try and edit a different database and see if I run into the same problem.  I have replaced the files with the original uncorrupted set many times in order to start fresh.

Amanda Snow

unread,
Dec 11, 2019, 1:16:33 PM12/11/19
to ArcSWAT
I attempted to edit other inputs.
Under Edit SWAT Input -> Subbasins Data ->.Ops, I was able to add an operation and save successfully.  I was also able to edit Weather Generator Data & Carbon Parameters per HRU under the same menu and save successfully.  
Under Edit SWAT Input -> Watershed Data -> Water Quality Data, I was able to edit and save edits.  
Though I haven't tried every possible edit, it seems that I can successfully edit every input except the mgt2 table.  

Soon, I *will* need to delete and add operations (in addition to editing existing operations).  I will try and do this in Access but appreciate the warning you've provided.  

Thanks for your response; I greatly appreciate any help.

-Amanda

Amanda Snow

unread,
Dec 11, 2019, 3:45:17 PM12/11/19
to ArcSWAT
After editing the Access mgt2 table and rewriting input files for mgt.dat, the exported data did not change in any way.  We believe there would be great changes associated with changing this harvest date.  The fact that there are no changes leads me to believe the mgt2 edits were not taken into account for the model run despite rewriting the .Mgt input files.

Jim Almendinger

unread,
Dec 11, 2019, 3:58:57 PM12/11/19
to Amanda Snow, ArcSWAT
Check the mgt text files in txtinout to confirm whether the changes you made to the mgt2 table in the project database were written properly (or not).  What were the great changes that you were expecting that you did not see?  If the mgt text files are properly written, then perhaps there are other factors in the model obscuring the presumptive effects of the mgt changes. 
-- Jim


James E. Almendinger, PhD
Director, St. Croix Watershed Research Station
16910 152nd St N, Marine on St. Croix, MN  55047


On Wed, Dec 11, 2019 at 2:45 PM Amanda Snow <as...@mlj-llc.com> wrote:
After editing the Access mgt2 table and rewriting input files for mgt.dat, the exported data did not change in any way.  We believe there would be great changes associated with changing this harvest date.  The fact that there are no changes leads me to believe the mgt2 edits were not taken into account for the model run despite rewriting the .Mgt input files.

Confidentiality Notice: The information in this transmission (including any attachments) is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. If you are not the intended recipient, any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information is prohibited. The user of this information is NOT authorized to copy, attach, transmit, or include this information in any bid or proposal without the authors explicit authorization. If you have received this in error, please contact MLJ-LLC at (530) 756-5200 and destroy all copies of the original message.

--
You received this message because you are subscribed to the Google Groups "ArcSWAT" group.
To unsubscribe from this group and stop receiving emails from it, send an email to arcswat+u...@googlegroups.com.

Amanda Snow

unread,
Dec 11, 2019, 4:39:54 PM12/11/19
to ArcSWAT
The date modified on the TxtInOut files did not change even though it said it successfullly rewrote the .mgt database.  Does that mean that it did not rewrite them successfully afterall?

I changed the harvest date to two months earlier for a crop so I was expecting, for that crop, to see a difference in yield, stress, biomass, leaf area index, etc.

Jim Almendinger

unread,
Dec 11, 2019, 5:12:49 PM12/11/19
to Amanda Snow, ArcSWAT
Yes, the file creation dates and times should change when the mgt text files are re-written (I'm pretty sure) -- so it sounds like they are not being re-written.  I don't know why that would be so, unless the mgt1 and mgt2 tables were somehow corrupted and the re-write process aborted.  I'd think you'd get an error message in that case from ArcSWAT. 
Again, a non-answer -- sorry.
-- Jim


James E. Almendinger, PhD
Director, St. Croix Watershed Research Station
16910 152nd St N, Marine on St. Croix, MN  55047


On Wed, Dec 11, 2019 at 3:39 PM Amanda Snow <as...@mlj-llc.com> wrote:
The date modified on the TxtInOut files did not change even though it said it successfullly rewrote the .mgt database.  Does that mean that it did not rewrite them successfully afterall?

I changed the harvest date to two months earlier for a crop so I was expecting, for that crop, to see a difference in yield, stress, biomass, leaf area index, etc.

Confidentiality Notice: The information in this transmission (including any attachments) is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. If you are not the intended recipient, any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information is prohibited. The user of this information is NOT authorized to copy, attach, transmit, or include this information in any bid or proposal without the authors explicit authorization. If you have received this in error, please contact MLJ-LLC at (530) 756-5200 and destroy all copies of the original message.

--
You received this message because you are subscribed to the Google Groups "ArcSWAT" group.
To unsubscribe from this group and stop receiving emails from it, send an email to arcswat+u...@googlegroups.com.

Ervin K

unread,
Dec 12, 2019, 7:29:39 AM12/12/19
to ArcSWAT
The following probably will not help you, but Ill throw out some ideas...

I was getting these "Unhandled exception..." errors when I would leave the database open in Access and tried to edit it via ArcSWAT.

Are you also saying that when you go to "Edit SWAT Input"->"Rewrite SWAT input files" that no txt files in the TxtInOut folder are changed and you do not get any error? In that case, I would make sure that the correct database is edited via ArcSWAT...because it would be really strange that the database gets edited and the txt files do not change after rewriting...

Also when you save Operation Schedules then they are placed in the SWAT2012 database (in your project folder) in the "OpSchedules" table. If you look at the "Crop" table in the same database you can see that the last column is the default OpSchedule for that crop, so perhaps a workaround for you would be to just create new default crop schedules and have them applied to the crops by editing the last column in the "Crop" table.

Last thing...Check your ArcGIS versions, was the initial model developed with an older version of ArcGIS and ArcSWAT? Otherwise I guess you just have to create the model from scratch...you do have all of the input data so it is only the crop management that would take time...
To unsubscribe from this group and stop receiving emails from it, send an email to arc...@googlegroups.com.

Amanda Snow

unread,
Feb 6, 2020, 3:22:57 PM2/6/20
to ArcSWAT
It turned out that my database was too large to open in Access (where it is edited).  To get around that, I have to edit it directly in the Access table.


Reply all
Reply to author
Forward
0 new messages