|
DataSet ds = new DataSet();
DataTable dt1 = new DataTable();
dt1.Columns.Add("PK", typeof(int));
DataTable dt2 = new DataTable();
dt2.Columns.Add("FK", typeof(int));
DataRelation Join = new DataRelation("Join", dt1.Columns[0], dt2.Columns[0]);
ds.Relations.Add(Join);
|
|
|
|
|
Shouldn't you have replied against the OP rather than somebody questioning where the post should go?
|
|
|
|
|
This is exactly what all the MSDN examples show. My questions are:
1. This code is for the case where we have a query like "SELECT something FROM dt1, dt2 WHERE dt1.PK=dt2.FK". Will this also hold good for a query like "SELECT something FROM dt1 JOIN dt2 on (dt1.PK=dt2.FK)"?
2. How does the statement
DataRelation Join = new DataRelation("Join", dt1.Columns[0], dt2.Columns[0]);
change if in case of a JOIN, I have a FULL JOIN, or a LEFT JOIN, or an OUTER JOIN etc.?
It's better to know some of the questions than all of the answers.
Pravin.
|
|
|
|
|
I agree this is more of a db question, but you're answer may not lie in thinking of the dataset as two tables. The underlying query will contain a join, but the dataset will still only contain a single result set table.
|
|
|
|
|
A JOIN produces one table, not two.
|
|
|
|
|
Ignore the people who say this is a database question. They probably have never worked with a DataRelation object and don't realize that ADO.Net allows you to essentially create an entire relational database in a DataSet.
The parent child relationships are determined by the cardinality of the two tables. If for every record in table A there can be many records in table B, then A is the parent and B is the child and vise versa. In the case of a left join, the table that may have nulls is always the child. In the case of a many-to-many relationship you should create two DataRelations, one in each direction.
|
|
|
|
|
And how does that answer the question?
|
|
|
|
|
Is there any function to return the kind of drive?
|
|
|
|
|
Hi,
I know three ways to get some information on physical devices:
1.
using the DriveInfo class
2.
using WMI, have a look at the WMI classes Win32_DiskDrive, Win32_LogicalDiskToPartition, Win32_PhysicalMedia, Win32_CDROMDrive; which ones you want depends on the information you need.
warning: not everything may be available to regular users under Vista/Win7 without going trough the UAC dialog.
3.
using Win32 functions (from kernel32.dll), which requires P/Invoke. Here is an example prototype:
[DllImport("kernel32.dll")]
public static extern int GetDriveType(string rootPathName);
For each of these, I refer to the MSDN documentation, Google, and some experimentation.
|
|
|
|
|
Hi, I have a server/client application. I want to block the clients' desktops to prevent pc usage. I also want to show a picture on the screen. Currently, I show a form covering the whole screen with topmost property set to true but it doesn't help much. Is there a better way to achieve that? Thanks!
|
|
|
|
|
Are you familiar with "kiosk mode"? if not, ask Google.
|
|
|
|
|
Hi Luc, Regarding to google results, some uses shell and some use win forms just like I do to implement kiosk. Is this what you mean or there is a speacial implementation for kiosk mode. Sorry to bother you
|
|
|
|
|
all I know is it is called kiosk mode, there are some CP articles on it, and Google knows everything.
|
|
|
|
|
|
Thanks, the reference helped a lot
|
|
|
|
|
So the DataBindingComplete event tells me when the data binding for a control is finished but is there a way to check at any point whether or not the data binding for a control is finished? (ie not event driven)
What I'm trying to achieve is this:
I have two DataGridView controls on a form bound to different data sources and I have some code that I'd like to execute when either of their data binding operations are finished. So far so good, I write an event handler which consumes both of their DataBindingComplete events.
The problem is I also have some code which I want executed only once both of the controls are done with their data binding. I don't know for which control the event handler will fire first so it would have been convenient if I could do something like:
if (dataGridView1.isDataBindingComplete && dataGridView2.isDataBindingComplete)
{
}
I suppose I could maintain a global boolean or something but I'm sure there must be a more elegant way. Any ideas?
|
|
|
|
|
Since the DataBindingComplete event hands you the sender parameter containing the DataGridView which has completed binding, and the EventArgs which tells you the reason, why not just use the Tag property?
Set it to true when it binds and check if both tags are true at the end of the event handler.
Simple, and elegant.
[edit]I can't spell for toffee this morning![/edit]
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
|
Hi,
I would like to know that how to get the list of methods in OCX and how to invoke the particular method with the input parameters in run time?
|
|
|
|
|
You need to have a look at COM interop - see here[^].
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
My latest tip/trick
Visit the Hindi forum here.
|
|
|
|
|
When you add an ocx to your project, it appears as a reference. You can have a look into all the methods of the ocx using the object browser of visual studio.
|
|
|
|
|
Hi all,
Create a ListView and an ImageList to go with it. Set the following:
Set the ImageList.ImageSize to 250 x 250 in the editor and then add some images - it'll automatically scale them up if you use small images but, for this test, that won't matter at all.
Create a textBox somewhere for the feedback string you're about to get.
Define the ListView as:
ListView1.View=LargeIcon;
ListView1.LargeImageList = ImageList1;
Now create some items for the collection - three is plenty for now - only top level items and don't add any text; you want to show a row of thumbnails to the user, no text or sub-children.
Now, put the following code behind the MouseMove event for the ListView:
Point cp = ListView1.PointToClient (new Point(e.X, e.Y));
ListViewItem TheNode = ListView1.GetItemAt(cp.X, cp.Y);
if (TheNode == null)
{
textBox1.Text = "nothing";
return;
}
textBox1.Text = "item " + TheNode.Index.ToString() + " selected";
My ListView is 1000 wide and not that high (300) so I should get all three items in a horizontal row - and I do - but when I move the mouse around, I'm getting some very bizare feedback from GetItemAt(). In some cases, I get a null until I'm about 50 pixels below a ListItem and when I'm within the bounds of the ListItem image, I'll get a null!
Am I exceptional or is this normal behaviour? If it's normal, anyone know what on earth I can do to mitigate it? My users will be able to define a range of thumbnail sizes and have control over the size of the ListView at runtime.
SysInfo: .NET 4 / VS 2010 / XP SP3 / ex-Pascal hack on keyboard. SysInfo[3] = usual cause of errors 
|
|
|
|
|
DaveGriffith wrote: Point cp = ListView1.PointToClient (new Point(e.X, e.Y));
I don't understand why you would do this, the coordinates are already relative to the receiver of the mouse events, hence ListView1.
|
|
|
|
|
Hi Luc,
Mainly because I'm trying to debug the problem I'm getting with sorting and DragDrop. When I try to use list reordering from an example Drag and Drop ListView row reordering
Using the e.X, e.Y values work as you suggest for my mouse move, why does every example I see of DragDrop use PointToClient() because it doesn't appear to report the right information to me when I try it in a mousemove event and I'm getting very bizarre re-ordering in my results! Heck, even MS use it in their example of OnDrop and I can't work it out.
|
|
|
|
|
Mouse coordinates are relative to the Control they apply to. If you have a MouseDown event on a Panel, the Panel is active and gets its event with local coordinates. MSDN holds examples where e.Location is used directly for painting something inside a Control.
There are only a few exceptions, and they always clearly state "in screen coordinates"; they apply to situations where there isn't an active Control, e.g. when you drop something (DragDrop.Drop event), or just ask for the mouse location (Control.MousePosition); for these, chances are you want to relate the event to the underlying Control, and then you would need Control.PointToClient.
Try it without PointToClient!
And check the MSDN documentation.
|
|
|
|