|
I am trying to determine primary key in a table wher Table is fetched from sql server database, but following code is not returning me Primary Key.
private void GetPrimaryKeys(DataTable myTable)
{
DataColumn[] pkSource;
pkSource = myTable.PrimaryKey;
for (int i = 0; i < pkSource.Length; i++)
{
Console.Write(pkSource[0].ColumnName[i]);
}
}
|
|
|
|
|
Make sure that you mytable contains information about the existing table fetched from sql server
|
|
|
|
|
I have a decimal value that I need to evaluate in an IF statement however I'm getting an error that reads "Operator '>' cannot be applied to operands of type 'decimal' and 'double'". What am I doing wrong?
Here's my code:
------------------
decimal totalRecPct;
totalRecPct = Decimal.Divide(4,7);
if(totalRecPct > .10)
{
//perform process here
}
----------------
Thanks.
-Goalie35
|
|
|
|
|
you need to cast one value to the other type.
if(totalRecPct > Decimal(.10))
|
|
|
|
|
Compare it to a decimal value:
if (totalRecPct > .10M)
---
single minded; short sighted; long gone;
|
|
|
|
|
Hi,
Please let me know how to populate the erst of the code where I have indicated with ????
In brief, I am looping through a hashtable which contains several hashtables and a dictionary.
The bit where indicated as ???? is where it goes through the items in the dictionary to retrieve ket and value.
Thanks
foreach (DictionaryEntry de in Globals.CacheHashTablesMain)
{
Hashtable subHT = de.Value as Hashtable;
if (subHT != null)
{
foreach (DictionaryEntry deSub in subHT)
{
string k = deSub.Key.ToString();
string h = deSub.Value.ToString();
}
}
else
{
????
}
}
|
|
|
|
|
You haven't stated what you're trying to do in that part of the code.
|
|
|
|
|
|
Greets @ all
I am writing a installer helper module for a program my company puts out. This module is kind of a dummy c#2005 module that just creates and sets the properties on an account for our program to use for it's service to use, while only having the rights it needs. I am having trouble getting the account properties set to their proper values, however. What I still need to do to this accounts it:
* make it not logon-able (when installed on xp i should see no entry on the welcome screen, server and xp without welcome screen should just disallow direct logon) but it of course, still needs to be usable for running a service under
* no profile directory created
* added to local Backup Operators group
Now, if i remember correctly, no profile is actually created until the first logon, so that should not be an issue.
Thanks for any insight anyone can provide
ccitt
|
|
|
|
|
So what i need to do is apply the SeDenyInteractiveLogonRight right to the account.
Does anyone know how to do this in C#? (preferably using DirectoryEntry)
Thanks again
ccitt
|
|
|
|
|
hi
i want to change color of some words in my richTextBox, and i write this code :
string str = this.richTextBox1.Text;<br />
char[] ch = new char[] { ' ' };<br />
int num = 0;<br />
foreach (string s in str.Split(ch))<br />
{<br />
if (s == "that")<br />
{<br />
int indexStart = this.richTextBox1.Text.IndexOf(s);<br />
this.richTextBox1.Select(indexStart, s.Length);<br />
this.richTextBox1.SelectionColor = Color.Red;<br />
num++;<br />
}<br />
}<br />
this.textBox2.Text = num.ToString();
but only change color of the first word that found, and not change color of all words that found, what is my problem and how to solve it ?
thanks
|
|
|
|
|
It's because you're finding the index of the first instance. Use one of the overloads of String.IndexOf[^] to specify a starting index that does not include the last found item.
|
|
|
|
|
Hey everyone,
I have a dataset which stores the results of a query that retrieves information from three tables . The thing is i bound it to a binding navigator and now i want to display the fields in text boxes or labels . My problem is, i dont know how to bind the navigator to the text boxes. The navigor has information in it, 3 records to be exact which was returned from my query, but now i dont know how to view it in a series of text boxes .
This is a code sample:
where bs is my binding source,
bngLoop is my binding Navigator,
and ds is my data set;
{
ds.Load(read, LoadOption.OverwriteChanges,
new string[{ "Result" });
bs.DataMember = "Result";
bs.DataSource = ds;
bngLoop.BindingSource = bs;
txtName.DataBindings.Add(new Binding("Text", bs, "Result.Client_Name", false));
}
i keep on getting this error:
DataMember Property 'Result' cannot be found on the DataSource.
Please help me
Phoenix
Phoenix
|
|
|
|
|
Hi,
I have a propertyholding object, that I use a PropertyGrid to view and edit.
The property I am having problems with is of type TimeSpan.
When the property is displayed in the PropertyGrid, it is done in the format hh:mm:ss, and nothing I do can convince the Grid, that I should be allowed to enter TimeSpans greater than 23:59:59!
If I programmatically enter a greater value and then bind to the grid, it correctly displays the value and even lets me edit it...
Please help out poor, simple noob!
Here's the (pseudo-)code of the object, I pass to the PropertyGrid:
public class PropertyHolder
{
Private TimeSpan _Duration;
PropertyHolder(){}
[...]
Using System;
Using System.ComponentModel;
[CategoryAttribute("Base Properties"), Browsable(true),
BindableAttribute(false), DescriptionAttribute("The time this Activity is planned to take.")]
public TimeSpan Duration
{
get { return _Duration; }
set { _Duration = (TimeSpan)value; }
}
}
Sincerely
Michael Barner
|
|
|
|
|
Hello Michael,
from what I can read in the docs, the format that will be understood when Parse is called is [-][d.]hh:mm:ss[.ff]
Anyway this is a very good case candidate for the new Smart FieldPackEditor component. I will allow edition of time durations in an intuitive manner.
|
|
|
|
|
I am coding a "Trace" object. This object will report the "method name" of the method within the class that the code is currently executing. I do not want to have to type in the method name each time the trace object is called. I simply want to be able to pass my object some sort of reflections.method.name.Tostring() call. This methodology can then be transported everywhere in all the methods without having to worry about misspelling or renaming the method down the road.
Eric "Moose Man"
|
|
|
|
|
eunderwo00 wrote: I am coding a "Trace" object
"Well done"
|
|
|
|
|
Jon Hulatt wrote: using System.Beer
Right now on my desk,
using System.Beer.Becks;
|
|
|
|
|
|
hi,
i'm looking fo a way to enable/disable my network connetion, via code.
after toggling, is there a way to know that i reached the wanted status? is there event i can catch to know if i'm connected/disconnected?
thanks.
|
|
|
|
|
|
hi,
i saw this link, but as i asked before - i wolud like to that in c#. any ideas?
thanks
|
|
|
|
|
Hey guys, I'm having a problem double buffering my control.
The control requires the UserPaint flag set to false, so I manually paint the control. Now since the control is painted over and over again I experience some flickering problems. What is the best way to create a custom like double buffer which prevents my control from flickering? The OptimizedDoubleBuffer style does not work when UserPaint is set to false.
<br />
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);<br />
this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);<br />
this.SetStyle(ControlStyles.Selectable, false);<br />
this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);<br />
this.SetStyle(ControlStyles.UserPaint, false);<br />
|
|
|
|
|
|
Hi,
Does anyone know whether it is possible to write managed code that utilised the L1 and L2 cache? The reason I'm asking is because it is faster to access the L1 and L2 cache.
Thanks
kk
|
|
|
|