|
Jason, you posted a VB.NET question in the C# forum.
led mike
|
|
|
|
|
Vb.net and c# are the same thing, more people visit this forum so I figure there is a better chance of getting an answer here.
|
|
|
|
|
Jason Weibel wrote: Vb.net and c# are the same thing
led mike
|
|
|
|
|
Here is the C# version - I'm really not interested in getting into a C# is better then vb debate. I just want get this working so I can move on to the next item on my to do list.
private void List(string listUrl, string username, string password) <br />
{ <br />
StreamReader reader = null; <br />
FtpWebRequest listRequest = WebRequest.Create(new System.Uri(listUrl)); <br />
System.Net.ServicePointManager.CertificatePolicy = new TrustAllCertificatePolicy(); <br />
listRequest.Method = WebRequestMethods.Ftp.ListDirectoryDetails; <br />
listRequest.KeepAlive = true; <br />
listRequest.EnableSsl = true; <br />
listRequest.Credentials = new NetworkCredential(username, password); <br />
FtpWebResponse listResponse = listRequest.GetResponse(); <br />
reader = new StreamReader(listResponse.GetResponseStream()); <br />
}<br />
<br />
public class TrustAllCertificatePolicy : System.Net.ICertificatePolicy <br />
{ <br />
public bool CheckValidationResult(System.Net.ServicePoint srvPoint, System.Security.Cryptography.X509Certificates.X509Certificate certificate, System.Net.WebRequest request, int certificateProblem) <br />
{ <br />
return true; <br />
} <br />
}
|
|
|
|
|
Jason Weibel wrote: I am attempting to read an SFTP directory using the FtpWebRequest class
Are you sure the Server is running?
led mike
|
|
|
|
|
|
Yes this entry from that blog holds the key
Actually, .NET 2.0 does not currently support implicit SSL, only explicit. We will consider adding this for a future release.
led mike
|
|
|
|
|
Visual c# express on Win XP x64
I wrote this part of the code:
<br />
for (int i = 1; i < 11; i++)<br />
{<br />
for (int j = 1; j < 11; j++)<br />
{<br />
dataGridView1[i, j].Value = "0";<br />
}<br />
}<br />
and the program seem to be returning form the method on the first } it encounters.
Debugging also shows that it starts doing the first for the goes to the 2nd one and when the 2nd one is finished it just drops out of the method.
but as for:
<br />
private int test()<br />
{<br />
int g;<br />
for (int i = 0; i < 9; i++)<br />
{<br />
g = 88;<br />
}<br />
g = 99;<br />
return g;<br />
}<br />
99 is returned.
Any ideas what might be wrong?
Long live open source - Free source.
|
|
|
|
|
The only reason that I could imagine for dropping out of a loop like that would be if the dataGridView1 did not contain 11 x 11 items so that you get an IndexOutOfRangeException exception, and that you have a try...catch somewhere that it will skip to.
Are the indices really one based, not zero based?
---
b { font-weight: normal; }
|
|
|
|
|
Thank you.
It was that I did not generate enough rows.
But it seems strange to me that the program did continue just normally as I don't have any Try/Catch statements.
It was in : private void Form1_Load(object sender, EventArgs e); If that may be the reason.
Thank you for the help
Long live open source - Free source.
|
|
|
|
|
Killer_XYZ wrote: But it seems strange to me that the program did continue just normally as I don't have any Try/Catch statements.
It can't continue just normally, as there was an exception. If you don't catch it anywhere it will just bubble up to the application level, where IIS will log it and create an error page for the user.
---
b { font-weight: normal; }
|
|
|
|
|
was up all..any way after i have mad aconnection between c# and sql ..i wrote the code below to select frist name ,depratment no of the employess from my data base (company)..its run..but there was logic error !!
the code:
private void button4_Click(object sender, System.EventArgs e)
{
sqlcon.Open();
sqlcom.CommandText="select fname,dno from emp where ssn="+txt.Text+"";
SqlDataReader x = sqlcom.ExecuteReader ();
if(x.Read())
{
txtfname.Text=x.GetString(1);
txtdno.Text=x.GetDecimal(3).ToString();
}
else
{
MessageBox.Show("NOT FOUND");
}
sqlcon.Close();
}
note: the fname int ist sec columns and the dno in the 4th cloumn.>>>waiting...
|
|
|
|
|
jemi jets wrote: note: the fname int ist sec columns and the dno in the 4th cloumn.>>>waiting...
Need typing lessons?
What exactly is the error.
|
|
|
|
|
thanks for ur help..i have fixed my error..and about the typing lessons stuff..iam working on it man..cheers up
|
|
|
|
|
jemi jets wrote: note: the fname int ist sec columns and the dno in the 4th cloumn.>>>waiting...
Need typing lessons?
What exactly is the error?
|
|
|
|
|
FRom the format of your message, I'd guess the code has a typo.
Should ssn be in single quotes ( is it a text field ) ?
|
|
|
|
|
hi there
i'm trying to bind data from a datatable to a combobox.
when i try to do it with the datasource property, it gives me the exceptionCannot modify the Items collection when the DataSource property is set.
i have previously bound data using the datasouce property to another combo on the same form.
can anyone help???
Saira
|
|
|
|
|
here are many stupid bugs with Items and DataSorce. You cannot use DataSource if you use Items. You cannot use Sorted if you use DataSource and so on...
But to your question: before clearing the ComboBox, unselect any selected item (reset it to null).
Or change DataSource this way:
1.) set DataSource to null
2.) set another object to DataSource
Parwej Ahamad
|
|
|
|
|
thanks for the big help
perwaiz
regards
Saira
|
|
|
|
|
Thanks Dear,
If u have further problem u can mail me.
g_parwez@rediffmail.com
Parwej Ahamad
g_parwez@rediffmail.com
|
|
|
|
|
Hi !
I have an app created with C# with an MDI and a bunch of forms/reports.
Besides the MDI, I also have a form that can help users by showing what forms are there in the app. This form has BUTTONS only. and When any of them is pressed, that particular form will be opened and added to the MDI ... so on and so forth.
The problem is, when a FORM is closed, its memory is not released, because that other form with BUTTONS still has its reference. And I guess Garbage collection anticipates it might be used again.
How can I explicitly FREE MEMORY of a FORM OBJECT in a situation like this ?
I have tried from within the FORM_CLOSING, no luck.
Thanks much
c#
|
|
|
|
|
C#_Dude wrote: The problem is, when a FORM is closed, its memory is not released, because that other form with BUTTONS still has its reference.
Are you sure? Why would that form hold on to the references?
C#_Dude wrote: How can I explicitly FREE MEMORY of a FORM OBJECT in a situation like this ?
Normally you never free memory, you only make sure that the objects are properly closed and get rid of the reference to them, then the garbage collector will eventually collect them.
It's normal for objects to remain in memory a while after you have released them. The garbage collector makes a collection when it's convenient or when it's needed. There is no reason to collect objects when there is no immediate demand for memory.
---
b { font-weight: normal; }
|
|
|
|
|
The garbage collector frees an object when there are no references left. So, if your buton retains a reference to a form, then it will not be GC'd. The garbage collector does not anticipate anything. Once you've removed your last reference to an instance of an object, you cannot get that instance back again at all.
How does your button-form know "what forms are there in the app"?
Do you mean it shows what forms are open and displayed?
If so, then - the standard convention is to use entries on the Window menu for that- it's been standard windows UI behaviour since the 3.0 days at least.
|
|
|
|
|
Hi,
I have an xml file which contains the history of send sms messages.
I loaded the xml file into a datagridview. The problem is, i don't know how i can load the data back into their controls.
I got two controls where data can be typed in. The first one is phone number which is a textbox.
And a richtexteditor where the message can be typed in. But my xml file contains 3 nodes.
Node 1 = date and time in ticks.
Node 2 = phone number.
Node 3 = message.
So if a row in the datagridview gets clicked/selected, it should load the phone number in the textbox and the message in the richtextbox.
Thanks in advance!
|
|
|
|
|
Check out Databinding.
The idea is that you have a BindingSource object that acts as the intermediary between the DataSource (the datatable with the data) and the input forms.
check out the CP article here for more specifics: http://www.codeproject.com/vb/net/databindingconcepts.asp[^] Its in vb, not C#, but the concepts are the same, and the displays will really help explain it to you.
|
|
|
|