|
there is a exception when i create DirectoryEntry .
code:
DirectoryEntry parent = GetDirectoryEntryByDn(path);
<big><b></b> DirectoryEntry user = parent.Children.Add("CN=" + user_name, "user");</big>
try
{
string oGUID = string.Empty;
user.Properties["samAccountName"].Value = user_name;
user.Properties["telephoneNumber"].Value = "15014088110";
user.Properties["streetAddress"].Value = "HZ";
oGUID = user.Guid.ToString();
user.CommitChanges();
}
catch
{ }
user.Close();
parent.Close();
the program run the line :
DirectoryEntry user = parent.Children.Add("CN=" + user_name, "user")
,the excpetion happened:
the exception InteropServicesCOMException "The specified Directory object is not bound to a remote resource" (and Error code
property is -2147463159)
please help me !
|
|
|
|
|
Try using the capabilities of System.DirectoryServices.AccountManagement to do this. See this[^] message for some ideas.
|
|
|
|
|
Hello CP!
Alright, I thought this would be simple, but apparently I don't know what I am doing. I have a Rich Text Box that populates upon form load. There are fields that are meant to be updated by text boxes on this form. Here's a snip of the form_load:
private void Form1_Load(object sender, EventArgs e)
{
string cifTime = timeCIF.Text;
string chkCIF = "N";
emailBody.Text = "Example\nCIF = " + chkCIF + "\nTIME = " + timeCIF.Text;
}
So what happens here is the form opens and populates a rich text box with:
Example
CIF = N
TIME =
Now, what I need to have a button do is update just the items I have defined, in this case chkCIF (a check box) and timeCIF.Text (a textbox). I have a button that's called update, and here's what it looks like.
private void updateButton_Click(object sender, EventArgs e)
{
if (comboInst.Text == "Example")
{
if (checkCIF.Checked == true)
{
string theString = emailBody.Text;
theString.Remove(3, 2).Insert(3, "Y");
}
}
And there you have it. I just need to be able to update certain defined words from a string with a click of a button. Thanks in advance
|
|
|
|
|
Goaty65109 wrote: update certain defined
Okay.... you are replacing/removing the text but then throwing the result away. You need to set your emailBody.Text back to the string that you have updated.
emailBody.Text = theString.Remove(3, 2).Insert(3, "Y");
|
|
|
|
|
Aha! I knew I was missing something so simple...
I am running into my next problem...
That removes items in position 3, over 2 spaces.
How do I tell it to do ROW 2, position 3, over 2 spaces?
And thank you so much for the speedy response.
|
|
|
|
|
Goaty65109 wrote: ROW 2
I don't know too much about it but I do not believe that the stock rich text box supports the concepts of rows.... A cheap easy way to do what you want would be to split your string (Split function) replace the text in the resulting array and then rejoining the array back into a string. Easier than is sounds.
Or you can replace your stock control with something like Line Numbers for RichText Control in C#[^]
|
|
|
|
|
Hey Phantom,
I understand what you're saying there and if a rich text box isn't the best way I think I can work backwards on what I want to do then.
How about writing the information to a text file, then calling it to the text box once it's updated in the text file?
Here is the "flow" of things:
Form loads and a .txt file is generated as a template.
User checks the box which makes the N turn into a Y in the text file.
User inputs the time into a text box.
User clicks the "Update Form" button which saves the text document and then pulls the entire document into the rich text box revealing the changes.
Does that sound like a better option? This just creates a new situation I have yet to attempt, but is on my "to learn" list, writing information to a specified position in a text file/reading from a text file.
Thank you for your response
|
|
|
|
|
No, please don't bring a text file into this. It will not make it any easier to replace your substrings and you will just be complicating matters.
See Richard's answer below, it seems like a much better solution.
Soren Madsen
"When you don't know what you're doing it's best to do it quickly" - Jase #DuckDynasty
|
|
|
|
|
Goaty65109 wrote: a text file
A text file would just add unnecessary complexity IMO. I would probably do this just as Richard suggested.
|
|
|
|
|
emailBody.Text = emailBody.Lines[1].Remove(3, 2).Insert(3, "Y");
|
|
|
|
|
Hi Rikki!
I tried this method and it appears that this will clear the emailBody and replaces it with just the first line, and replaces the third position with Y.
So this
Example
Blah = N
turns to this
ExYmple
I just want this if possible
Example
Blah = Y
Haha, sorry for my illiteracy, I am trying to be as specific as I can with the knowledge I have. :P
|
|
|
|
|
For example:
private void SomeForm_Load(object sender, EventArgs e)
{
string cifTime = timeCIF.Text;
string chkCIF = "N";
emailBody.Text = "Example\nCIF = " + chkCIF + "\nTIME = " + timeCIF.Text;
}
private void SomeBtn_Click(object sender, EventArgs e)
{
string[] sLines = emailBody.Lines;
sLines[1] = emailBody.Lines[1].Remove(6, 1).Insert(6, "Y");
emailBody.Lines = sLines;
}
|
|
|
|
|
Why not keep all the individual pieces of text as separate variables and then rebuild the RichTextBox [^] using its methods, whenever an item changes? This should make it much easier to add or remove specific items in the future.
Use the best guess
|
|
|
|
|
|
Thanks.
Use the best guess
|
|
|
|
|
i want to display a graph,i related it to my database "powerdb" it has a table called powertable with 2 attributes: "power" and "time",but when i run it,nothing appeares. only a white window.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
powerdbDataSet db = new powerdbDataSet();
private void Form1_Load(object sender, EventArgs e)
{
this.powertableTableAdapter.Fill(this.powerdbDataSet.powertable);
chart1.Series[0].XValueMember = "time";
chart1.Series[0].YValueMembers ="power";
powertableBindingSource.DataSource = db.powertable;
}
private void chart1_Click(object sender, EventArgs e)
{
}
}
}
Thank you for your help.
|
|
|
|
|
Hi,
you are not filling the data into your db variable:
this.powertableTableAdapter.Fill(this.powerdbDataSet.powertable);
this line should be
this.powertableTableAdapter.Fill(tdb.powertable);
Regadrs
Jegan
Think! Don't write a line of code unless you absolutely need to.
|
|
|
|
|
thank you very much ,now it works perfectly
|
|
|
|
|
Hey guys, I am trying to create a matrix which allows a user to either turn a square on or off by clicking it. It needs to be 6X8 squares. So far all I can think of is creating 48 buttons, or maybe even a panel split into 48 sections? I am looking for a solution that is not too complex, so any advice on how to do start this would be much appreciated!
Thank you!
|
|
|
|
|
The answer will depend on which User Interface system you are using: Windows Forms or WPF (or web based...).
|
|
|
|
|
I am using Windows Forms!
Thanks!
|
|
|
|
|
Override panel and override the mouse click and mouse move event and OnPaint event. An array of buttons is simpler but you will be happier with results the other way. Neither Windows Forms nor WPF likes a lot of controls and the correct answer a lot of times is custom controls. With such a simple case you will have the opportunity to learn a valuable tool to put in your toolbox.
|
|
|
|
|
Thanks for your input and your advice, I appreciate it. I will look into how to do what you suggested, I am new to this kind of thing! Thank you!!!
|
|
|
|
|
I'd make a Panel or Group with Buttons. But that's just me.
|
|
|
|
|
Hi All,
I have created a program which extracts metadata out of a PST. This data has then been stored in a text file.
I am trying to create a set of charts/graphs which will represent the data which I have pulled out. Is it possible using Visual Studio 2010 to create a bar chart for example using variables or by reading specific data which I have written to the text file.
I know that VS 2010 does have the inbuilt chart feature; however, I can't seem to get it to work off values held in a variable (only from databases, a service, an object or SharePoint).
I am new to programming in C# and using Visual Studio so I may be missing something very simple! I have googled for days and have had no light.
Any assistance would be much appreciated.
Many thanks,
Katie.
|
|
|
|