|
Hi,
I am developing program to connect to the windows server 2003.
i want to copy some folders from server PC to client PC through my program. if i do this without program then windows pops up for username and password to connect to the server. But in my program how can i handle pop up or how can i connect to the server?
Thanks for reply.
yogesh
|
|
|
|
|
public string RemoteConnection(string targethost, string targetusername, string targetpassword)
{
StringBuilder result = new StringBuilder();
try
{
ConnectionOptions Conn = new ConnectionOptions();
if (targethost != Environment.MachineName) //WMI errors if creds given for localhost
{
Conn.Username = targetusername; //can be null
Conn.Password = targetpassword; //can be null
}
ManagementScope scope = new ManagementScope(targethost , Conn);
scope.Connect();
return result.ToString();
}
catch
{
return "fail";
}
}
yogesh
|
|
|
|
|
helo yogesh_softworld123
I can't find ConnectionOptions's definition, what's its Namespace ?
thanks a lot~
|
|
|
|
|
Hello,
Here's what I'm trying to do. I need to create a toolbar that will post username/password to a webpage, get a cookie as response, and save that cookie so that the browser has access to it. Right now, I am able to send a post and save the response with the following code:
private bool getCookie()
{
HttpWebRequest request;
try
{
string dest = "http://" + ip;
string p = "username=un&password=pass";
MessageBox.Show("Sending a request to: " + dest + " with creds: " + p);
request = (HttpWebRequest)WebRequest.Create(dest);
request.CookieContainer = cookieJar;
request.Credentials = CredentialCache.DefaultCredentials;
request.Method = "POST";
Byte[] byte1 = Encoding.ASCII.GetBytes(p);
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = byte1.Length;
Stream newStream = request.GetRequestStream();
newStream.Write(byte1, 0, byte1.Length);
newStream.Close();
}
catch (Exception e)
{
MessageBox.Show(e.Message);
MessageBox.Show("Please ensure correct IP address.");
return false;
}
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
if (response.Headers["Set-Cookie"] == null)
return false;
string[] cParams = response.Headers["Set-Cookie"].Split('=');
string cName = cParams[0];
string cValue = cParams[1];
MessageBox.Show("Cookie name: " + cName + " Value: " + cValue);
myCookie = new Cookie(cName, cValue);
myCookie.Expires = DateTime.Now.AddHours(1);
response.Cookies.Add(myCookie);
response.Close();
return r;
}
However, I do not think the cookie is being saved. Also, I don't really want to have it expire in 1 hour, I would prefer it to expire at end of session, but not sure how. I want the browser to have access to the cookie for future navigation. Essentially the toolbar logs the user in and performs the first query to the system. Future queries are likely to be done thru the web interface. I tried using an HttpCookie, but I couldn't pass it to Cookies.Add() since it wants a Cookie and not HttpCookie. I tried manually adding the cookie to the header of navigate/2 by:
string h = "Cookie: name=value";
Object header = h;
navigate/2(url, null, null, null, header);
and it does add to the header, but the page does not log me in :/
Any help appreciated!
Mike
FREE 28 player online game @ http://www.1483online.com where the community drives enhancements to the game!
|
|
|
|
|
I have a delete button on my windows form and a data grid view with a check box column. Now what I want is to let the user select values he wants to delete by checking the check boxes. Now when he clicks the Delete button not only the selected values be deleted from the grid view but also be deleted from the database.
|
|
|
|
|
Loop through the rows in the datagridview
identify the record that is checked
Delete it from the database
reload the DGV
Loop through the rows in the datagridview in REVERSE
identify the record that is checked
Delete it from the database
Delete the row from table/list supporting the DGV
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
List<points> points = new List<point>();
i need to know how can i empty the list class(i.e. clear all the points i have created on the form) at button click event...please help !
|
|
|
|
|
What concretely is List ? Is your own class? Which items you want to clear?
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
the one that exists already not my own.
protected override void OnPaint(PaintEventArgs e)
{
foreach (Point dot in dots)
{
// code to create marks in form of small circles using e.graphics
}
base.OnPaint(e);
}
i wish to delete those circles now..!!
|
|
|
|
|
Then you call dots.Clear(); . For what it's worth, you can find this information by searching MSDN
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
it had not worked...i have used e.graphics.DrawEllipse to get my small dots n the appear on mouse clicks..
|
|
|
|
|
Wow. You even said it. dots.Clear();
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
ya i had tried that but its not working..any clue why..??
|
|
|
|
|
OK, well, perhaps you need to ask the right question. The clear method DOES work, obviously. So, there's something wrong with your code. We'd need to see the code to be able to suggest what it is.
One guess, do you call Invalidate() after you clear the list, and if not, what were you expecting to cause a paint event ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Hi all,
I was creating a ToolStripe with a few Buttons.
I was creating a SplitButton. This Button has Items.
i.e:
Start Program 1
Start Program 2
Start Program 3
How can I get the select Text of the items ?
My sample returns only the name of the split button
MessageBox.Show("ITEM: " + item.Name + " " + ButtonBenutzerAuswahl.Selected.ToString());
|
|
|
|
|
Have you tried the item's Text property?
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
no the item.text will not return the value of the selected DropDownItems
|
|
|
|
|
What type of items are you adding to your split button, and what value so you expect or want to get from them?
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
i have tow qutions
1-how i can create query wizard in c sharp
2-i need add the result form query to colume in datagridview control
note
i am using c sharp .net
|
|
|
|
|
1 - what do you mean by query wizard ? To talk to a DB ? You connect, you take input, and you run it on the DB.
2 - Then you add a column and put the values in there
mohammad alnoed wrote: note
i am using c sharp .net
Well, in this forum, of course you are.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
yes I was creating connection to access database using wizard connection
but i do not know how i can create query by wizard
after that i need to add the result to colume in datagridview
datagridview1.Rows[1].cell[2].vlaues="i want add the query wizard here";
thanks
|
|
|
|
|
I have a class called CardHolder which extends UserControl. I have overrode its OnPaint function like so:
protected override void OnPaint(PaintEventArgs e)<br />
{<br />
base.OnPaint(e);<br />
<br />
Graphics g = e.Graphics;<br />
<br />
foreach (Card c in this.Controls)<br />
{<br />
g.DrawImage(c.Image, c.Location);<br />
}<br />
}
Each image is tied to a Control which has been added to this control. Each image is a partially transparent image which is partially overlaid another image. However, each time the OnPaint function is called, it doesn't clear the Control of what was there before:
Good: http://img20.imageshack.us/i/goodw.jpg/[^]
Oh dear: http://img24.imageshack.us/i/ohdearz.jpg/[^]
I've hooked into the CardHolder's Resize event and call PositionCards in that function to position the Controls, which in turn calls OnPaint behind the scenes. I hope what I'm doing here makes sense to you guys. How do I clear the Control of the previously drawn images?
Card extends UserControl as well but is transparent and has no child controls.
modified on Tuesday, July 21, 2009 12:36 PM
|
|
|
|
|
How is the OnPaint being called? Call the Refresh() method to make your control invalidate the graphic and repaint itself.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
I don't know how OnPaint is being called. I'll give Refresh a try.
[Edit]
Thanks Nagy Vilmos.
modified on Tuesday, July 21, 2009 12:35 PM
|
|
|
|
|
i want to filter report made by Crystal Reports
and i made it by the wizard
and here is an example so i want to pass the value of the field of Employee Name For example from a textbox or another contorle by the user then the report appears the records that the user want to display
and many thanks for you
http://ahmedkhallaf.brinkster.net/WindowsFormsApplication1.rar[^]
Allah bless the prophet Mohammed
|
|
|
|