|
Is there a way to run an app as a system-user on the compact framework?
I need to do some stuff with the certificate store, and I keep getting no-permission errors..
Help would be much appreciated !
|
|
|
|
|
I'm quite certain that the Windows Mobile supports RunAs.
|
|
|
|
|
Allright, that's good to know!
Then I'll just have to find out, how to actually do it.
|
|
|
|
|
I have a datagrid with a dataset table as it's datasource and a tree with a copy of the original dataset table as it's datasource. The datagrid dataset can be changed, but the tree needs to stay constant.
This is for a biology app. After I add nodes for each Family\Genus\Species to the tree I want to go back through it and add a (number) after each node to designate how many collections are under each node.
This works fine on faster processors but not on slower as the processors hit 100% and take up to 8 minutes to run. It takes 8 seconds when it doesn't hit 100%.
Here is the code that adds the (number) after each node:
public void AddCollectionsToNodes()
{
this.collectionTree.SuspendLayout();
this.CollectionsDataGrid.SuspendLayout();
string oldFilter = "";
if(dsCollections.Tables[0].DefaultView.RowFilter != null)
{
oldFilter = dsCollections.Tables[0].DefaultView.RowFilter;
}
try
{
foreach(TreeNode all in this.collectionTree.Nodes)
{
foreach(TreeNode family in all.Nodes)
{
string filter = "";
if(oldFilter.Trim().Length > 0)
{
filter = oldFilter + " AND Family_Name='" + family.Text + "'";
}
else
{
filter = "Family_Name='" + family.Text + "'";
}
dsCollections.Tables[0].DefaultView.RowFilter = filter;
int rowCount = dsCollections.Tables[0].DefaultView.Count;
family.Text += " (" + rowCount + ")";
if(rowCount > 0)
{
foreach(TreeNode genus in family.Nodes)
{
int count = 0;
for(int i = 0; i < rowCount; i++)
if(dsCollections.Tables[0].DefaultView[i]["Genus_Name"].ToString().Trim() == genus.Text.Trim())
count++;
genus.Text += " (" + count + ")";
if(count > 0)
{
foreach(TreeNode species in genus.Nodes)
{
count = 0;
for(int i = 0; i < rowCount; i++)
if(dsCollections.Tables[0].DefaultView[i]["Specific_Epithet"].ToString().Trim() == species.Text.Trim())
count++;
species.Text += " (" + count + ")";
if(count > 0)
{
foreach(TreeNode infra in species.Nodes)
{
count = 0;
for(int i = 0; i < rowCount; i++)
if(dsCollections.Tables[0].DefaultView[i]["Infra_Epithet"].ToString().Trim() == infra.Text.Trim())
count++;
infra.Text += " (" + count + ")";
}
}
}
}
}
}
}
}
}
catch ( System.Exception e)
{
MessageBox.Show (String.Format ("Error: {0}", e.Message), "Add Number of Collections to Family Nodes");
}
dsCollections.Tables[0].DefaultView.RowFilter = oldFilter;
this.collectionTree.ResumeLayout();
this.CollectionsDataGrid.ResumeLayout();
this.collectionTree.Nodes[0].Expand();
}
Thanks for any ideas!
RABB17
|
|
|
|
|
Look at the number of nested for loops you have and its no wonder it pegs the processor.
If you need to get the number of child nodes use node.Nodes.Count.
|
|
|
|
|
Problem is, (number) is not the number of child nodes, it's the number of collections that will be seen in the datagrid for that particular parent/child/child node.
|
|
|
|
|
Can you return the number of these collections from the database? Get a second resultset from your query and use it to populate the treeview.
|
|
|
|
|
Populate the treenode by issuing a select that returns COUNT and put that number in the node.
|
|
|
|
|
What is the best way to return more than one value back from a method?
I have a method that I'm calling that I want to return back some data, a primary key, and the datetime stamp. I was thinking of returning a struct back, but was wondering if there was a better way?
Tom
|
|
|
|
|
A struct or some out variables on the signature, depending on if the struct makes any sort of sense beyond being a way to return the values.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
You can also use "out" paramaters, which let you pass information back as a write only variable.
private string ReturnStuff(out var1, out var2)
{
var1=something;
var2=something;
return primaryKey;
}
Note these are Write-Only variables.
Aaron
|
|
|
|
|
Hi,
i need to display the selected folder name from a browse folder dialog on clicking "ok" button in another dialog in a text box,the user should not be able to edit this, i have disabled the text box on creation itself.Please help me with the code since i have to deliver my application by tomorrow evening.
Awaiting ur replies
Thanks
Shruthi
|
|
|
|
|
To pass info between forms, use a delagate.
x2pca wrote: Please help me with the code since i have to deliver my application by tomorrow evening.
That's very troubling.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Indeed. Asking for answers without try does not benefit students at a long run. It looks like a side effect of forum.
Best,
Jun
|
|
|
|
|
Hello guys, Jun, Christian
Well, why don't we help the newbies with code snippets? This would encourage them, and give them a head start, wouldn't it?
I mean.. Is it "cheating" if we help them with a line or two, just as an assistance in their projects? I don't endorse it as a habit, yet I think they sometimes deserve more help than mere general guidance don't you agree?
Regards
|
|
|
|
|
Yes, by all means. We should help those who have tried, not those who just pass the assignment to us.
Best,
Jun
|
|
|
|
|
Well, it sounds fair enough for me.
Thanks Jun.
Regards
|
|
|
|
|
x2pca wrote: Please help me with the code since i have to deliver my application by tomorrow evening.
Yeah right!!
If you're a student, get used to the fact that nobody is going to do your job for you. Nobody.
If you are already in the industry, why have you not figured that out yet?!?!?!?!?!
Good luck. The clock is ticking...
:josh:
My WPF Blog[^]
|
|
|
|
|
hi,
I create a dataset and fill it with access database. everything is fine, I can see the data in the binded grid control. but i have an exception when I do the copy operation. the exception says, the dataset can not pass the constrains (non null, foreign key...).
I think I can not create the first dataset if the data is wrong?
does anyone have idea about this?
Thanks a lot!
Alan Shen
MCAD for .NET Version
^~^~^~^~^~^~^~^~^~^~^
Great idea is the beginging of success!
|
|
|
|
|
DataTable has two methods, BeginLoadData and EndLoadData, which can be used when copying data into the table to prevent constraints from being enforced temporarily. Try using those when copying the data.
:josh:
My WPF Blog[^]
|
|
|
|
|
I am coding a interest calculator in C# using Visual Studio 2005 Express edition and I keep on getting the following error: "CalcBalance does not exist in the current context". I am not sure what's cuasing it or how to fix it. Any advice which would help in get this code working would be greatly appreciated. Below is the full code:
<%@ Control Language="C#" ClassName="WebUserControl" %>
protected void Button1_Click(object sender, EventArgs e)
{
Label6.Text = "Final Balance: $" +
CalcBalance(Convert.ToInt32(TextBox1.Text),
(Convert.ToInt32(TextBox2.Text) / 100),
Convert.ToInt32(TextBox3.Text),
Convert.ToInt16(DropDownList1.SelectedItem.Value)).ToString();
}
private string CalculateBalance(int Principal, double Rate, int Years, int Period)
{
double result;
double NumToBeRaised = (1 + Rate / Period);
result = Principal * System.Math.Pow(NumToBeRaised, (Years * Period));
return (result.ToString("C"));
}
<asp:label id="Label1" runat="server" style="position: relative" text="Compound interest Calculator" width="318px" font-bold="True" font-size="Large">
<asp:label id="Label2" runat="server" style="position: relative" text="Principal ($)" width="165px">
<asp:textbox id="TextBox1" runat="server" style="position: relative">
<asp:label id="Label3" runat="server" style="position: relative" text="Rate (%)" width="165px">
<asp:textbox id="TextBox2" runat="server" style="position: relative">
<asp:label id="Label4" runat="server" style="position: relative" text="Years:" width="165px">
<asp:textbox id="TextBox3" runat="server" style="position: relative">
<asp:label id="Label5" runat="server" style="position: relative" text="Compound Frequency:" width="165px">
<asp:dropdownlist id="DropDownList1" runat="server" style="position: relative">
<asp:listitem value="1">Annually
<asp:listitem value="4">Quarterly
<asp:listitem value="12">Monthly
<asp:listitem value="365">Daily
<asp:listitem>
<asp:button id="Button1" runat="server" style="left: 9px; position: relative; top: 10px"
="" text="Calculate" width="207px" onclick="Button1_Click">
<asp:label id="Label6" runat="server" style="position: relative" width="165px">
Greg
The Belizean Dan Dada!!!
|
|
|
|
|
Are you kidding?
You are calling a function named CalcBalance but you have defined one with the name CalculateBalance . Do you see the difference?
|
|
|
|
|
protected void Button1_Click(object sender, EventArgs e)
{
Label6.Text = "Final Balance: $" +
CalcBalance(Convert.ToInt32(TextBox1.Text),
^^^^^^^^^^^ -- LOOK AT WHAT YOU TYPED HERE :~
(Convert.ToInt32(TextBox2.Text) / 100),
Convert.ToInt32(TextBox3.Text),
Convert.ToInt16(DropDownList1.SelectedItem.Value)).ToString();
}
private string CalculateBalance(int Principal, double Rate, int Years, int Period)
^^^^^ - NOW LOOK AT WHAT YOU TYPED HERE :omg:
{
double result;
double NumToBeRaised = (1 + Rate / Period);
result = Principal * System.Math.Pow(NumToBeRaised, (Years * Period));
return (result.ToString("C"));
}
|
|
|
|
|
By looking at your code, it seems as CalculateBalance(...) is the function that actually calculates the interest but you are using CalcBalance instead of CalculateBalance(...) as the name of the function.
If the name of the interest calculating function is actually CalcBalance, then this error might be because CalcBalance is not in the current class.
Regards,
Wasif Ehsan
|
|
|
|
|
wasife wrote: If the name of the interest calculating function is actually CalcBalance, then this error might be because CalcBalance is not in the current class.
"this error might be..." You are too kind, Wasif
:josh:
My WPF Blog[^]
|
|
|
|