|
Right on the first part, wrong on the rest.
A DataRelation is the analog of a SQL Server foreign key constraint. It does relate two DataTables on a user-defined key in a parent/child relationship. It does not, however, merge the columns of two or more DataTables into a unified view.
There's ample information in MSDN on this topic.
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|
|
I currnetly have a reporting method that works well for one user at a time, but these reports have gained popularity within my organization. If more than one user uses it at the same time they get overlapping data.
Current setup is using a c# application that uses crystal reports to view info from a MSSQL database table. The problem is that they all use the same table. The application gahters data from a couple of databases, makes some decisions based on the information gathered, and writes all of the data to this one table.
I'm running into a wall trying to make this more dynamic. Any ideas on how I can give each user their own data to work with?
Jeff Guerrero
|
|
|
|
|
|
Odds are the startup project in your solution is set to a class library project, and not an executable project.
As the message indicates, you can't execute a class library - there's nowhere for your application to start (e.g. a Main method).
In Solution Explorer, right click on an executable project and set it as the startup project.
Hope this helps.
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|
|
Yes that seems to have worked. There was a Main method in one of the projects.
What get me is
1. Why this was not defined as the startup project in the .sln file.
2. Why I had to do this manually. Why does VS not look for the Main menhod and set that to the startup project?
Thanks. I now know what do in the future!!
Liam
|
|
|
|
|
My guess is that, since the startup project is only relevant to debugging (unless people normally double-click on .DLL files and sit there wondering why they didn't execute), and the person executing the solution for debugging should be able to figure out which project they'd like to execute, and should know that class libraries are not executable, the VS team opted not to add the feature.
For instance, what if your project had 20 console applications, and no class libraries at all? Should Studio randomly choose one of the console apps as the startup project? Select them all?
The startup project is actually saved in the solution options file (*.SUO), so unless you delete the file or it becomes invalid, you should only have to set it once.
I just did a little experiment with a console application and class library on my desktop. Killing the SUO file and reopening the solution resulted in the console application being chosed for startup by default every time, even if I explicitly chose the class library previously, and doesn't appear to rely on which project was added to the solution first, so I'm guessing there is at least a little intelligence in Studio for choosing...
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|
|
Hi all experts,,,,
i have a problem,that i have developed a module(window application) in which
there is a tree control.In tree control there are items in nodes of tree control.I want to select the item and do right click on that item and i got a popmenu.means that as the menu we use in our common applications which contain cut,copy etc.
Plz help me as soon as possible.
With regards
Ishtiaq Ahmed
|
|
|
|
|
Do as under:
1. In the designer mode, drag a ContextMenu control from the ToolBar to the Form (on which your TreeView control is placed). It is named as ContextMenu1.
2. Add items (as per your requirement) to this ContextMenu instance in the space provided therein (with the prompt of "Type here") as you would while building a normal menu.
3. In the designer mode itself, now select your instance of TreeView control and in its Properties window, select the ContextMenu property and assign the value of the aforesaid instance "ContextMenu1" which you have just designed.
4. Now, just compile and run it. When you right-click on a node, you'll see a popup menu with the items you just placed as above.
5. For adding functionality to the menu items in the aforesaid ContextMenu, use the eventhandler for the click event of the particular menu item.
|
|
|
|
|
hi every body,
i want to create multifile assembly that contain (c# class and access database )
c# class read some data from the database and view it by any way
i tray to make this but....
when use the dll (multifile assembly ) in another project the dll was not feel with the database that already contained in the dll........
<<< abo hassan >>>
|
|
|
|
|
The database file is not part of the compiled assembly, even if you added the file to the solution explorer. When you move the assembly to a different location, you need to move the database with it or provide a central location where the database may be accessed (a file share or something).
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|
|
I've been trying to figure out how much of the CPU a process has been using within a time span. I need to know its usage as well as any child processes that are spawned. To get the process tree I used WMI so I can query the processes with a parent process Id.
Trouble is, I'm getting insane results. Here's my code:
<br />
<br />
Process pTool = ....<br />
<br />
ManagementScope oMs = new ManagementScope();<br />
UInt64 iPreviousTime = 0;<br />
DateTime dtPreviousTimestamp = DateTime.Now;<br />
<br />
pTool.Start();<br />
<br />
while (!pTool.HasExited)<br />
{<br />
pTool.Refresh();<br />
UInt64 iCurrentTime = (UInt64)pTool.TotalProcessorTime.Milliseconds;<br />
<br />
iCurrentTime += GetProcessTime(oMs, (uint)pTool.Id);<br />
<br />
DateTime dtNow = DateTime.Now;<br />
<br />
UInt64 iDiff = iCurrentTime - iPreviousTime;<br />
TimeSpan tsDiff = dtNow - dtPreviousTimestamp;<br />
<br />
float fPercent = (float)(iDiff) / (float)tsDiff.Milliseconds;<br />
<br />
string strDebug = string.Format("Elapsed time: {0}\tProcess time: {1} ({2})",<br />
tsDiff.TotalMilliseconds, iDiff.ToString(), fPercent.ToString());<br />
Debug.WriteLine(strDebug);<br />
<br />
iPreviousTime = iCurrentTime;<br />
dtPreviousTimestamp = dtNow;<br />
<br />
System.Threading.Thread.Sleep(1000);<br />
}<br />
<br />
private UInt64 GetProcessTime(ManagementScope oMs, uint iParentId)<br />
{<br />
ObjectQuery oQuery = new ObjectQuery("select Name,ProcessId,UserModeTime,KernelModeTime from win32_process where ParentProcessId=" + iParentId.ToString());<br />
ManagementObjectSearcher oSearcher = new ManagementObjectSearcher(oMs, oQuery);<br />
ManagementObjectCollection oReturnCollection = oSearcher.Get(); <br />
UInt64 iTotalTime = 0;<br />
foreach (ManagementObject oReturn in oReturnCollection)<br />
{<br />
string strName = oReturn["Name"].ToString();<br />
uint iProcessId = uint.Parse(oReturn["ProcessId"].ToString());<br />
<br />
UInt64 iUserModeTime = UInt64.Parse(oReturn["UserModeTime"].ToString()) / 10000;<br />
UInt64 iKernelModeTime = UInt64.Parse(oReturn["KernelModeTime"].ToString()) / 1000;<br />
<br />
Debug.WriteLine("Parent: " + iParentId.ToString() + "\tProcess: " + iProcessId.ToString() + " (" + strName + ")\tTime: " + (iUserModeTime + iKernelModeTime).ToString());<br />
<br />
UInt64 iChildTime = GetProcessTime(oMs, iProcessId);<br />
<br />
iTotalTime += (iChildTime + iUserModeTime + iKernelModeTime);<br />
}<br />
return iTotalTime;<br />
}<br />
Here's the output I get in the debug window:
Parent: 5248 Process: 5984 (java.exe) Time: 530
Elapsed time: 825.2365 Process time: 576 (0.6981818)
Parent: 5248 Process: 5984 (java.exe) Time: 2046
Parent: 5984 Process: 2744 (mtwrapper.exe) Time: 0
Elapsed time: 1152.217 Process time: 1516 (9.973684)
Parent: 5248 Process: 5984 (java.exe) Time: 2359
Elapsed time: 1043.2235 Process time: 313 (7.27907)
Parent: 5248 Process: 5984 (java.exe) Time: 2421
Parent: 5984 Process: 3216 (ipconfig.exe) Time: 171
Elapsed time: 1074.3645 Process time: 233 (3.148649)
Parent: 5248 Process: 5984 (java.exe) Time: 2468
Elapsed time: 1089.935 Process time: 18446744073709551492 (2.072668E+17)
Parent: 5248 Process: 5984 (java.exe) Time: 2499
Elapsed time: 1027.653 Process time: 31 (1.148148)
As you can see, it starts off fine in the first iteration and then it seems to start going crazy. In the second iteration the java process has over 2 seconds but the elapsed time is just over a second. Further down, the huge number must mean we got a negative result. Also confusing.
Can anyone see anything really dumb that I'm doing? If not, has anyone done something like this before?
Thanks,
Michael Stone
|
|
|
|
|
If anyone's interested, I found the problem. Two stupid mistakes.
First:
<br />
UInt64 iKernelModeTime = UInt64.Parse(oReturn["KernelModeTime"].ToString()) / 1000;<br />
should be:
<br />
UInt64 iKernelModeTime = UInt64.Parse(oReturn["KernelModeTime"].ToString()) / 10000;<br />
ie, missed a zero in the divide.
Second:
<br />
float fPercent = (float)(iDiff) / (float)tsDiff.Milliseconds;<br />
shoud be:
<br />
float fPercent = (float)(iDiff) / (float)tsDiff.TotalMilliseconds;<br />
otherwise we divide by the remainder, not the total number of elapsed milliseconds.
With these changes it works quite well. Hope it's useful to someone.
Michael Stone
|
|
|
|
|
|
Hi All,
I am just starting to learn C#, and here is my question..
I leanred how to establish a connection with an OleDB database and read and write to it, but now I am trying to do the same with a DB2 connection..
--what do I have to do differently?
--I found some hints leading to getting a .dll file. Is that correct? If so, where can I find that .dll file and how do I use it in my code?
Thanks for the help.. any hint will be greatly appreciated
E.T.
|
|
|
|
|
Hi ET:
Since you have connected to a OLEDB driver-based database, with DB2, you need not invoke directly any DLL methods.
Use the DB2 OLEDB Provider.
When you install IBM DB2 Client on Windows, you automatically get the OLEDB Drivers registered. I think the format would be like Provider=IBMDADB2...
Did this help you?
Deepak Kumar Vasudevan
Personal Web: http://vdeepakkumar.netfirms.com/
I Blog At: http://deepak.blogdrive.com/
|
|
|
|
|
Thanks for the hint, but it does not seem to be that simple...
When I run the program, at the point of trying to open the connection, it comes with an error "IBMDADB2" is not registered on your machine.
and actually it would say that about anything I put in for the Provider!!
|
|
|
|
|
Hi:
Have you install Client Tools/Connectivity options been properly selected whilst installing DB2 on your Windows system.
That installer takes the responsibility of registering the OLEDB Provider for DB2 on your system.
Deepak Kumar Vasudevan
Personal Web: http://vdeepakkumar.netfirms.com/
I Blog At: http://deepak.blogdrive.com/
|
|
|
|
|
I am guessing yes.. the person taking care of the Database on the IBM server came and set up my account. I can access the files on the server and even modify it if I want, but all manually, not through the C# code!
how Can I tell if I need to change the options??
THanks
E.T.
|
|
|
|
|
Hi Everyone:
I want a good way of putting in passwords into config files. I wanted to use a public encryption scheme. The way that I figured I would use was this. Generate a public private pair in advance and place this into the code in advance. Then place the public key into the config file. Then provide a seperate tool for the user to take that public key and encrypt the password. The only thing that I was concerned about was the storing of the private key so openly in the code.
What should I do to get around this?
Cheers,
Jim
Did I post well? Rate it! Did I post badly? Rate that too!
|
|
|
|
|
I'm personally against putting the private key in the code. I suppose you could obfuscate the code, possibly making it harder to read the key, but otherwise, anyone with ILDASM or Reflector could have it in minutes.
In my opinion, you're better off (unless you want to pursue some chip-based or biometric solution) just putting the key in a file in a secure (as in file permissions) location that you control. You could also use the registry, I suppose - that can be both secured and audited.
Hope this helps.
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|
|
Thanks for the suggestion, but I am afraid that the solution really does require it to be there. I just wish that there was a way to get it into code ahead of time. Unfortunately, I cannot take the permissions approach because this is actually meant to be a more general solutions approach, and as for the registry, we really dont want to use it. I know that there is a built in feature for storing the key, and that obfuscates the key for you. But I dont know how I could actually beging with that object in existence I am afraid.
Otherwise, does the structure of the solution seem ok?
Thanks a lot,
Jim
Did I post well? Rate it! Did I post badly? Rate that too!
|
|
|
|
|
I don't understand why a solution would require the private key to be embedded in the source code. Can you elaborate on that a little? I also don't understand what you meant by "...get it into the code ahead of time." or the idea that this is supposed to be a "more general approach". What does that mean? I can't imagine it's going to be very general in nature if you're planning on cooking the private key right into the assembly. You cant's get a lot more concrete than that. Are you planning to automatically create these assemblies and compile them on the fly or something?
That said, I can't answer your question about the structure of the solution. It's kind of like standing in an empty meadow and asking someone what they think of your new office building.
More info would be helpful.
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|
|
Hrmm, perhaps I didn't quite make my solution 100% clear. Basically, I NEED to have some sensitive data placed in the configuration file. My solution, was to pregenerate a public key, and have the private key placed right into the code. (Optimally one would like to generate that at run time, but that is not possible because the user is only going to configure this file once.)
Using the public key (which I would likely leave right in the configuration file) the user can encrypt theiry sensitive data, and then place that data in the config file. As the code would have the private key already, it would already be able decrypt the information in the config file.
I hope that is a little clearer,
Jim
Did I post well? Rate it! Did I post badly? Rate that too!
|
|
|
|
|
Apparently I missed something too. Are you suggesting that you are going to change the app.config file at runtime? If so, I would recommend against it, regardless of your plans for encryption. It's not a recommended place to keep dynamic config data.
As far as storing passwords in text files, with a private key embedded in source code, I don't think it's a great idea. Certainly it can be made to work.
Does your application use a database of any kind? Generally I just use a one-way salted hash to obscure passwords when there's a database.
Don't know if this helps or not, but I think I have a better understanding of what you're trying to do now.
Good luck.
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|
|
If you are putting the public key itself in the config file and you are also keeping the private key in the code somewhere, then where is the security of the data? In such a scenario, almost everybody having access to the cofig file will have access to the public key and can encrypt the sensitive data in your scheme of the things and store the same in the cofig file. Moreover, everybody can then simply use your program which will automatically decrypt the sensitive data by using the private key stored somewhere in the code. This is so because apparently you are not using any specific extra password etc from a particular user which can distinguish one user from another and which can bind it to a particular user.
Better course is to have (or create at run time at the time of first use by a user) a password which is encrypted with a one-way hash (with an appropriate salt for better security). Store that hash value (may be in a config file). Subsequently, when the user inputs that password at the time of a subsequent use of the program, it should again get the hash value of the password entered by the user and compare the same with the hash value stored at the time of the first use.
As for the encryption of the other data, the same can be done by using a symmeteric encryption by the aforesaid password the safety of which has been ensured by hashing it.
Hope it suits your requirements.
|
|
|
|
|