|
I have two DataTables (orders and orderitems) in my DataSet that use DataRelation on orderid. I am trying to create a third DataTable that will hold the result but I am having a lot of trouble doing this so that the code doesn't care what columns were selected. I have the columns of the new DataTable being created fine but how do you mix parent rows and child rows into a single DataRow?
Thanks for any help!
DataSet theDataSet = new DataSet();
//get orders
SqlCommand ordersCommand = new SqlCommand("select * from uc_orders where order_date > '03/01/2007'", theconn);
theadapter.SelectCommand = ordersCommand;
DataTable ordersDataTable = new DataTable("Orders");
theadapter.Fill(ordersDataTable);
//orderitems
SqlCommand orderItemsCommand = new SqlCommand("select * from uc_order_items where load_date > '03/01/2007'", theconn);
theadapter.SelectCommand = orderItemsCommand;
DataTable orderItemsDataTable = new DataTable("OrderItems");
theadapter.Fill(orderItemsDataTable);
//add both tables to dataset
theDataSet.Tables.Add(ordersDataTable);
theDataSet.Tables.Add(orderItemsDataTable);
//create a "join" called OrdersRelationship on order_id
theDataSet.Relations.Add(new DataRelation("OrdersRelationship", ordersDataTable.Columns[keyColumn], orderItemsDataTable.Columns[keyColumn], true));
//new table
DataTable ordersAndOrderItems = new DataTable();
//loop over all available columns in each table
foreach (DataColumn dc in ordersDataTable.Columns)
{
ordersAndOrderItems.Columns.Add(dc.ColumnName);
}
foreach (DataColumn dc in orderItemsDataTable.Columns)
{
if (!ordersAndOrderItems.Columns.Contains(dc.ColumnName))
ordersAndOrderItems.Columns.Add(dc.ColumnName);
}
theDataSet.Tables.Add(ordersAndOrderItems);
//parent loop, get child
foreach (DataRow parentRows in ordersDataTable.Rows)
{
DataRow[] childRow = parentRows.GetChildRows("OrdersRelationship");
foreach (DataRow allChildren in childRow)
{
????????????
//hardcoded answer
ordersAndOrderItems.Rows.Add(allChildren["order_id"], parentRows["order_id"], allChildren["store_items_id"], parentRows["last_name"]);
}
}
|
|
|
|
|
I solved it by adding the parent columns to the child DataTable and then filling it with data.
//create a "join" called OrdersRelationship on order_id
theDataSet.Relations.Add(new DataRelation("OrdersRelationship", ordersDataTable.Columns[keyColumn], orderItemsDataTable.Columns[keyColumn], true));
//add parent columns to child DataTable
foreach (DataColumn dc in ordersDataTable.Columns)
{
if (!orderItemsDataTable.Columns.Contains(dc.ColumnName))
orderItemsDataTable.Columns.Add(dc.ColumnName);
}
//add parent data to child DataTable
foreach (DataRow dc in orderItemsDataTable.Rows)
{
foreach (DataColumn pdc in ordersDataTable.Columns)
{
if (pdc.ColumnName != keyColumn)
dc[pdc.ColumnName] = ordersDataTable.Rows.Find(dc[keyColumn])[pdc];
}
}
|
|
|
|
|
I'm using the TcpClient(hostname,port) to retreive my emails, When the port is 110 and is not using a secure connection, i'm successful getting my email, however when I try to read my Gmail account the Tcp,Client just hangs there and there is no option to use the secure connection, how can I make this program connect to my gmail account?
|
|
|
|
|
Hi
You can use SecLib from Mentalis.Org to establish an SSL - Connection.
If you're looking for a Library that supports ssl check http://www.codeproject.com/cs/internet/pop_-_class.asp[^] it's going to be updated soon and the new version supports ssl
if you use the framework 2.x, there's a built-in library that supports almost the same things as the mentalis library does for the 1.x framework
greets
m@u
-- modified at 10:47 Wednesday 14th March, 2007
|
|
|
|
|
I'm using .net 2.x, What is the name of the package and also the name of the class.
|
|
|
|
|
|
I have a dll (a control derived from Label) and I would like to use the simple key/value configuration settings provided by App.config (or similar file). Visual Studio gladly creates this resource for me, encouraging me to think a dll can have its own settings.
This statement will always get a setting from the exe, what ever exe is using the dll.
string dbText = ConfigurationSettings.AppSettings["Foxpro_template"];
How can I have config settings for the dll control?
Lastly, I realize the configuration manager will manage 'machine' wide setting for me. That is nice but it always wants to place the user and machine settings under a 'mydocuments' folder. I would like to keep the entire suite under one folder so a user could duplicate an install with a simple copy and paste command. That is I want to keep machine and user settngs under folder C:\myproduct not c:\mydocuments. Any suggested readings or ideas?
Thanks
Phil
|
|
|
|
|
|
I have a lot of form: Form1, Form2,..,Form10. When the program start, a Main Form is show, Main form contain a Listview display a list form. I use Listview have CheckBox. User will choose a few forms which are needed display. The number of forms is varied and choosed form is varied. Do you kown the way programming this require? Pleased help me! I'm begin learning C#.NET 2005.
Thanks!
|
|
|
|
|
You can really make an array of Forms. Then cast to the proper type when required. For instance:
Form1 frm1 = new Form1();
Form2 frm2 = new Form2();
...
Form [] frmArray = new Form[n];
...
Form[i].Show();
frmArray[i].Show();
...
((Form1) Form[i]).MyCustomTextBox.Text="foo";
((Form1) frmArray[i]).MyCustomTextBox.Text="foo";
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
How can I get the list of valid domain users of the XP/2000 domain to which I belong ?
My aim is to develop a C# / VB.Net desktop application which can be accessed by valid users of my domain. I cannot have a user management section for my application. It has to detect all valid user of my domain and work among them. Nor users need not log into this application and still get data pertaining to them alone. Administrators can see list of users of domain and send messages etc. I hope, I made it clear.
Thank you
Madhu
|
|
|
|
|
Hi,
i've several prob/doubts abt CheckedListBox Control,
1), When i check(click on any value)- the checkbox which is inside the checkedlistbox is not toggling to checkedmode, but when i Double Click its working so,
please tell me why?and suggest me the solution.
2)i've inserted(loaded) the values in to this checkedlistbox from an xml file,
but now if i want to change the property of a perticuler node/childnode i couldn't able to do that,
3) please help me how to change the selected values [checked box values]
i mean , when user checks the checkbox and clicks the update button, the respective property has to change to eidt="true" of my xml file.,PLEASE HELP ME
I am using VS2005, for my c# windows applciation
prashanth,
s/w Engineer,
Syfnosys.
|
|
|
|
|
Hi all
I'm newbe to platform invoke in C#.
I need to retrieve the text of an item in a Listbox.
I should send a SendMessage sending a LB_GETTEXT message
with lParam as as a Pointer to the buffer that will
receive the string.
I always used this declaration for SendMessage that worked until now.
[DllImport("user32.dll", SetLastError = true)]
public static extern IntPtr SendMessage( IntPtr hWnd,
uint Msg,
uint wParam,
int lParam );
My problem is that I need to past to lParam a pointer to a string
or a buffer.
I tried using casting or directly StringBuilder object but
without success.
Do you know why this happens and how to use
this SendMessage to retrive the string I need?
Regards
ManuStone
|
|
|
|
|
If you need to use it with StringBuilder, declare it like so:
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
static extern IntPtr SendMessage(HandleRef hWnd, uint Msg, IntPtr wParam, StringBuilder lParam);
See P/Invoke.NET[^] for more info.
|
|
|
|
|
|
Can anyone tell me how to use a wait cursor, while some file execution is going on?
Consider the case. I have to load some file to a datagrid, which takes say approximately 8 seconds.
during that period, I want to show a wait cursor, so that the user has an idea that something is going on. Please tell me an easy way to do this.
Thanks in advance
Keshav Kamat
India
|
|
|
|
|
Take a look at the Cursor class.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
thanks i got it.
Cursor.Current = Cursors.WaitCursor;
// do work
Cursor.Current = Cursors.Default;
Keshav Kamat
India
|
|
|
|
|
I'm using a dictionary object to store data but it seems that it can't be ordered by the key name. I assumed that a dictionary would be ordered by key somewhat like one of those book things that you look words up in, you know those hmmm, what's the word, oh, dictionary things.
Do i need to write my own collection to support this behaviour?
Russell
|
|
|
|
|
Take a look at the SortedDictionary class.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Thanks
I'd been searching for dicionary sort; sortable dictionary and hadn't found anything
SortedDictionary looks just the thing
Thanks again
Russell
|
|
|
|
|
hi, I've created an XSD
but i am unable to validate that,
please suggest/guide me HOW TO VALIDATE A XML
i am using VS2005 &C# for windows applciation.
Thnx in advance,
prashanth,
s/w Engineer,
Syfnosys.
|
|
|
|
|
Validating XML Data with XmlReader[^]
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
I have one dataSet ds and one dataTable dt. In want to fill the table from dataset:
sommething like that:
ds.Tables["tab1"].LoadDataFromTable(dt);
// LoadDataFromTable not exist
|
|
|
|
|
Hi
To assign to dataset from datatable, use this:
ds = dt.DataSet;
Harini
|
|
|
|