473,387 Members | 1,453 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

strange datagrid problem

I'm having an odd problem with a datagrid in a c# program. The program
maintains a schedule of jobs that need to be run. As jobs run, the status
and next run date/time info are updated in a SQL database. On the initial
load, the datagrid fields are defined. The 1st time the dataset is reloaded,
an error is returned stating that the 1st field in the list is not found. On
all subsequent reloads, everything is fine. Here's the relevant code (I
chopped out as much as I thought I could and still illustrate the problem
areas). It seems like the problem is being caused by using the Process
object. If I comment out the portion of the routine that sets up and runs
the jobs, the grid always works. Any help solving this would be appreciated.

private void RunThisJob()
{
try
{
DataSet statusSet = midConn.GetData("JobMaster", "select * from
JobMaster where id = " + jobRow["id"].ToString());
statusSet.WriteXml(jobRow["xmlName"].ToString(),
XmlWriteMode.WriteSchema);
lastJobName = jobRow["jobTitle"].ToString();
theStatus.Text = DateTime.Now.ToShortDateString() + " " +
DateTime.Now.ToShortTimeString() +
" running " + lastJobName;
Process myProcess = new Process();
myProcess.StartInfo.FileName = jobRow["programPath"].ToString();
myProcess.StartInfo.Arguments = jobRow["configName"].ToString() + " " +
jobRow["xmlName"].ToString();
myProcess.Start();
myProcess.WaitForExit();
resultSet = new DataSet();
resultSet.ReadXml(jobRow["xmlName"].ToString(), XmlReadMode.ReadSchema);
resultRow = resultSet.Tables[0].Rows[0];
DoStatus((bool)resultRow["lastStatus"],
resultRow["lastMessage"].ToString());
}
catch(Exception ex)
{
SendConfirmation("Exception executing job " + lastJobName + ": " +
ex.Message, false);
theStatus.Text = "Exception executing job " + lastJobName + ": " +
ex.Message;
resultRow = null;
DoStatus(false, ex.Message);
}
finally
{
jobSet = midConn.GetData("JobMaster", "select * from JobMaster where id
= " + jobRow["id"].ToString());
jobRow = jobSet.Tables[0].Rows[0];
jobRow["lastRun"] = DateTime.Now;
ScheduleJob();
}
}

private void LoadSchedule(DateTime nextDate)
{
try
{
jobRow["nextRun"] = nextDate;
jobRow["retryCount"] = 0;
DataSet rd = midConn.PutData(jobSet.GetChanges());
jobSet = midConn.GetData("JobMaster", "select * from JobMaster order by
nextRun, jobTitle");
ShowJobs();
jobRow = null;
}
catch (Exception ex)
{
SendConfirmation("Exception writing next scheduled date for " +
lastJobName + ": " + ex.Message, false);
}
}

private void ShowJobs()
{
try
{
if (jobGrid.TableStyles.Count == 0)
{
jobStyle = new DataGridTableStyle();
jobStyle.MappingName = "JobMaster";
jobGrid.TableStyles.Add(jobStyle);
DataColumn jobID = (DataColumn)jobSet.Tables[0].Columns["id"];
jobSet.Tables[0].PrimaryKey = new DataColumn[1]{jobID};
jobGrid.SetDataBinding(jobSet, jobSet.Tables[0].TableName);
jobStyle.GridColumnStyles.Clear();
DataGridTextBoxColumn cs = new DataGridTextBoxColumn();
cs.MappingName = "jobTitle";
cs.HeaderText = "Job Name";
cs.Alignment = HorizontalAlignment.Left;
cs.Width = 350;
jobStyle.GridColumnStyles.Add(cs);
DataGridTextBoxColumn cs2 = new DataGridTextBoxColumn();
cs2.MappingName = "lastRun";
cs2.HeaderText = "Last Run";
cs2.Alignment = HorizontalAlignment.Left;
cs2.Width = 125;
cs2.Format = "MM/dd/yy hh:mm tt";
jobStyle.GridColumnStyles.Add(cs2);
DataGridTextBoxColumn cs3 = new DataGridTextBoxColumn();
cs3.MappingName = "nextRun";
cs3.HeaderText = "Next Run";
cs3.Alignment = HorizontalAlignment.Left;
cs3.Width = 125;
cs3.Format = "MM/dd/yy hh:mm tt";
jobStyle.GridColumnStyles.Add(cs3);
DataGridBoolColumn bs = new DataGridBoolColumn();
bs.MappingName = "active";
bs.HeaderText = "Active";
bs.Alignment = HorizontalAlignment.Left;
bs.Width = 50;
jobStyle.GridColumnStyles.Add(bs);
}
else
jobGrid.SetDataBinding(jobSet, jobSet.Tables[0].TableName);
}
catch (Exception ex)
{
theStatus.Text = "Error in ShowJobs - " + ex.Message;
}
}

Nov 17 '05 #1
0 1261

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Zeppo | last post by:
Hello, who can help me out on a strange problem? Ik created a small app with vb6p (on w2kp). It worked fine, and i copied the generated .exe (68k) on my laptop (XPH) It complained about some...
0
by: elime | last post by:
Hi all I have a strange behaving on some PC with my DataGrid. It only occurs on some PC, on others it works perfectly fine. ->(same ..net version installed) it's very confusing. starting...
5
by: EMW | last post by:
On my pc on which I created my aspx files, my site works fine. I use IIS5 and is does everything I want it to do. I moved my site to the networkserver (it's a intranet site) and then something...
1
by: Kepler | last post by:
I'm fighting a really strange bug that involves both a DataGrid and a Repeater disappearing on postback. The strange thing is that I've distilled the problem down to a simple program, that...
2
by: Tim_Mac | last post by:
hi, i have an aspx page which dynamically loads a user control and adds it to a placeholder. the control is recreated and added to the placeholder for postbacks as well. the user control...
2
by: sosh | last post by:
Hi, I'm having a strange problem with the update function of a datagrid: I have a datagrid, the first column lists item names from a database. Second column is an EditCommandColumn, and then I...
0
by: Wim Geukens | last post by:
Hi, We're experiencing a very strange session variable problem. We've got a running version of our site at www.mysite.com, which points to c:\mysite in IIS 5 This same site is also reachable...
8
by: Spam Trap | last post by:
I am getting strange resizing problems when using an inherited form. Controls are moving themselves seemingly randomly, but reproducibly. "frmBase" is my base class (a windows form), and...
3
by: simchajoy2000 | last post by:
Hi, I am using a datagrid which contains a dataset with several tables and I am experiencing an inexplicable behavior that I am unable to resolve. Perhaps it's due to the complexity of my...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.