I think this is more general c# question than ado.net....
Program worked ok, until I added method which puts this table in xml. I went debugging and on line marked program pops up my windows form and stops (waiting to trigger some event on that form by user (click button etc)). But Form shouldn't apear at this line in code. Why is this happening?
I have just started to learn c# and I'm new to visual studio 2010 (using it on win7 64 bit).Please some advice, maybe it is more about some VS 2010 setup that i'm not aware of.th
Without this newly added line everything is working as expected...
private DataTable BuildSampleTable()
{
// ------ Create a sample table to display in the application.
DataTable theTable = new DataTable("SampleTable");
theTable.Columns.Add("ID", typeof(long));
theTable.Columns.Add("StudentName", typeof(string));
theTable.Columns.Add("GradeYear", typeof(int));
theTable.Columns.Add("ScoreTrimester1", typeof(decimal));
theTable.Columns.Add("ScoreTrimester2", typeof(decimal));
theTable.Columns.Add("ScoreTrimester3", typeof(decimal));
// ----- Create a primary key for the table.
theTable.PrimaryKey = new DataColumn[] {theTable.Columns["ID"]};
// ----- Design the table structure.
result = new DataTable("Customer");
keyColumn = result.Columns.Add("ID", typeof(int));
result.Columns.Add("BusinessName", typeof(string));
result.Columns.Add("AnnualFee", typeof(decimal));
result.Columns.Add("ContractDate", typeof(DateTime));
result.PrimaryKey = new DataColumn[] {keyColumn};
// ----- Add some sample data.
result.Rows.Add(new Object[] {1, "City Power & Light",
500m, DateTime.Parse("6/1/2008")});
result.Rows.Add(new Object[] {2, "Lucerne Publishing",
300m, DateTime.Parse("1/1/2008")});
result.Rows.Add(new Object[] {3, "Southridge Video", // <--------------- windows form pops up
350m, DateTime.Parse("2/15/2010")});
return result;
}
it is really strange to me how can some code trigger show form, maybe it is better that i attach whole solution (it is from step by step vs 2010 from microsoft press)
nothing, as it was called with Form.Showdialog. It is just there, program stops and waiting to trigger some event. I have posted another post with complete solution from another program but moderator need to confirm it. It is same thing but form pops up when i'm bulding a table, pop up goes on table.rows.add(.....) method.
nothing, as it was called with Form.Showdialog. It is just there, program stops and waiting to trigger some event.
Well, don't call that if you don't want the form to appear.
Originally Posted by mata123
I have posted another post with complete solution from another program but moderator need to confirm it. It is same thing but form pops up when i'm bulding a table, pop up goes on table.rows.add(.....) method.
I'm a mod and I don't see any other posting from you. I downloaded your program and it starts up for me without any additional popups. I hit the 'generate' button and the program seems to generate xml. Are there other repro steps that I need to try?
and...oh my God, it seems this is an american version of code, and DateTime is in mm/dd/yyyy format, i guess on american computers (time setup) it works ok, I had to put all dates in dd/mm/yyyy format (chapter 7 solution)
try catch block discovered the problem, I didn't know that error could happened with no warning, I expect always at least that program crashes
for writexml problem... my program didn't have rights to write to root
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.