|
I just would like to ask for a sample code that really works on Downloading or Receiving files from the FTP.
I have these lines of code but seems like it don't work.
FtpClientConnection myftpClientConn = null;
public frmDbSynch()
{
InitializeComponent();
}
private void btnDBSynch_Click(object sender, EventArgs e)
{
String[] remoteFileNames = { "myTestFolder", "myFTPFolder" };
String localPath = @"C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup";
myftpClientConn.ReceiveFiles(remoteFileNames, localPath, true, true);
}
thanks
|
|
|
|
|
Good day all
I am writing an application that change the settings of a windows service once it is installed. For instance, depending on the options a user chooses, the service must log on as Local System Account or use a particular user account. If the service is set to log on using a user account, I should supply that user's logon credentials.
Is this achievable. If yes, how can I achieve?
Thanks in advance
Kulile --- RSA
|
|
|
|
|
What i need to do is to insert into a dataset. But the same method will insert into different type tables.
For instance, 1 table might have 5 columns, but another might only have 2.
<br />
foreach (DataRow theRow in dataClasses)<br />
{<br />
string className = theRow["Class_Name"].ToString();<br />
object[] nodeSets = new object[9];<br />
<br />
if (tempDataSet.Tables[0].Rows.Count != 0)<br />
{<br />
foreach (DataRow row in tempDataSet.Tables[0].Rows)<br />
{<br />
string CMDB_Version = row.ItemArray[4].ToString();<br />
string Service = row.ItemArray[5].ToString();<br />
string Label = row.ItemArray[6].ToString();<br />
string Managed = row.ItemArray[7].ToString();<br />
string Live = row.ItemArray[8].ToString();<br />
string URL = row.ItemArray[9].ToString();<br />
string Classification = row.ItemArray[10].ToString();<br />
string Grouping = row.ItemArray[11].ToString();<br />
string Profile_Name = row.ItemArray[12].ToString();<br />
<br />
nodeSets[0] = CMDB_Version;<br />
nodeSets[1] = Service;<br />
nodeSets[2] = Label;<br />
nodeSets[3] = Managed;<br />
nodeSets[4] = Live;<br />
nodeSets[5] = URL;<br />
nodeSets[6] = Classification;<br />
nodeSets[7] = Grouping;<br />
nodeSets[8] = Profile_Name;<br />
<br />
theSaveModelDataSet.Tables["New" + className].Rows.Add(nodeSets);<br />
}<br />
}<br />
}<br />
This is what i do at the moment, but this ofcourse will only work for 1 datatable.
So the question is, how do i create a peice of code that will insert the right amount of data into each column.
Regards,
Gareth.
|
|
|
|
|
Hi,
assuming each of the tables where you want to insert data has columns with the same names as the columns in the source table you could do something like this:
foreach (DataRow theRow in dataClasses)
{
string className = theRow["Class_Name"].ToString();
DataTable tableToInsertInto = theSaveModelDataSet.Tables["New" + className];
if (tempDataSet.Tables[0].Rows.Count != 0)
{
foreach (DataRow row in tempDataSet.Tables[0].Rows)
{
DataRow rowToInsert = tableToInsertInto.NewRow();
foreach (DataColumn column in tempDataSet.Tables[0].Column) {
if (tableToInsertInto.Columns.Contains(column.ColumnName)) {
rowToInsert[column.ColumnName] = row[column.ColumnName];
}
}
tableToInsertInto.Rows.Add(rowToInsert);
}
}
}
Robert
|
|
|
|
|
Thank you, it works wonderfully.
The next question is, how do i do the same, but instead of selecting from a dataset, i get the information from a datarow[]
<br />
DataRow[] newUserServiceRows = graphShared.MainDataSet.Tables["NodeChanges"].Select("stateChanged = " + (int)ServiceModeler.ModelerClass.StateChangeType.Added + " AND className = '" + className + "' AND userCreated = 'y'");<br />
<br />
foreach (DataRow theRow1 in newUserServiceRows)<br />
{<br />
string CMDB_Version = theRow1["Node_Version"].ToString();<br />
string Service = theRow1["Node_Key"].ToString();<br />
string Label = theRow1["Node_Key"].ToString();<br />
string Managed = "";<br />
string Live = "";<br />
string URL = "";<br />
string Classification = "";<br />
string Grouping = "";<br />
string Profile_Name = "";<br />
<br />
nodeSets[0] = CMDB_Version;<br />
nodeSets[1] = Service;<br />
nodeSets[2] = Label;<br />
nodeSets[3] = Managed;<br />
nodeSets[4] = Live;<br />
nodeSets[5] = URL;<br />
nodeSets[6] = Classification;<br />
nodeSets[7] = Grouping;<br />
nodeSets[8] = Profile_Name;<br />
<br />
theSaveModelDataSet.Tables["New" + className].Rows.Add(nodeSets);<br />
}<br />
Regards,
Gareth.
|
|
|
|
|
Hi,
that's nearly the same:
DataTable tableNodeChanges = graphShared.MainDataSet.Tables["NodeChanges"];
DataRow[] newUserServiceRows = tableNodeChanges.Select("stateChanged = " +
(int)ServiceModeler.ModelerClass.StateChangeType.Added +
" AND className = '" + className +
"' AND userCreated = 'y'");
DataTable tableToInsertInto = theSaveModelDataSet.Tables["New" + className];
foreach (DataRow row in newUserServiceRows)
{
DataRow rowToInsert = tableToInsertInto.NewRow();
foreach (DataColumn column in tableNodeChanges.Column) {
if (tableToInsertInto.Columns.Contains(column.ColumnName)) {
rowToInsert[column.ColumnName] = row[column.ColumnName];
}
}
tableToInsertInto.Rows.Add(rowToInsert);
}
Robert
|
|
|
|
|
Robert, the problem with the code you suggested is that the datatable im getting the data from isnt the same as the datatable im inserting into, thus the columns.contains will never match.
|
|
|
|
|
Well then you will have to do some more manual work:
DataRow[] newUserServiceRows = graphShared.MainDataSet.Tables["NodeChanges"].Select("stateChanged = " + (int)ServiceModeler.ModelerClass.StateChangeType.Added + " AND className = '" + className + "' AND userCreated = 'y'");
foreach (DataRow theRow1 in newUserServiceRows)
{
object[] nodeSets1 = new object[] {
theRow1["Node_Version"].ToString(), theRow1["Node_Key"].ToString(),
theRow1["Node_Key"].ToString(), "", "", "", "", "", "" };
theSaveModelDataSet.Tables["New" + className1].Rows.Add(nodeSets1);
object[] nodeSets2 = new object[] {
"", "",theRow1["Node_Key"].ToString(), theRow1["Node_XXX"].ToString()
theRow1["Node_YYY"].ToString(), "", "", "", "", "", "" };
theSaveModelDataSet.Tables["New" + className2].Rows.Add(nodeSets2);
object[] nodeSets3 = new object[] {
theRow1["Node_Key"].ToString(), theRow1["Node_Key"].ToString(),
"", "", "", "", "", theRow1["Node_Key"], "" };
theSaveModelDataSet.Tables["New" + className3].Rows.Add(nodeSets3);
}
This generally hardcodes how the object arrays for each destination table have to be generated. I just invented some combination. Thus you wil have to make it correct yourself.
Robert
|
|
|
|
|
Hi,
Is method hiding polymorphism?
_____________________________
Success is not something to wait for, its something to work for.
|
|
|
|
|
No
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
It can be and it can be not. It all depends upon situation.
sAqIb
"Our scientific power has outrun our spiritual power. We have guided missiles and misguided men."
Dr. Martin Luther King Jr.
|
|
|
|
|
Polymorphism is when derived classes do different things by overriding base methods. Hiding members does not fit that definition.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
but in actualy they are hiding the actual definition of the methods of base classes.
sAqIb
"Our scientific power has outrun our spiritual power. We have guided missiles and misguided men."
Dr. Martin Luther King Jr.
|
|
|
|
|
Oh, sure - they are replacing them.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Christian Graus wrote: they are replacing them
i agree with you Christian Graus.
what i understand is that c# suggest member hiding through the new keyword, means, a new member is defined in the derived class. while polymorphism is achived through overriding (which is not hiding).
_____________________________
Success is not something to wait for, its something to work for.
|
|
|
|
|
I have a base form and couple of derived forms.
I want to override Hide method of the base form. But the problem here is we have no facility to override hide method. How do I go about it?
Thanks in advance.
|
|
|
|
|
Hello,
I think you could use this for your base Forms class:
<br />
public new virtual void Hide()<br />
{<br />
base.Hide();<br />
}<br />
And this for your derived classes:
<br />
public override void Hide()<br />
{<br />
base.Hide();<br />
}<br />
Hope that helps you.
All the best,
Martin
|
|
|
|
|
Thanks Martin
I'll Try and let you know
|
|
|
|
|
Hi all,
I had a Console Application which name is myConsoleApp and now I want to run that Console Application from Windows App. How must I do?. For example:
The way to run my Console Application is:
myConsoleApp args1 args2
that purpose is convert args1 to args2 then save args2 to disk . Now I have a Windows Application with two Textboxes, The first Textbox's name is txtSource, the second Textbox's name is txtDest. I want to run my above Console Application with args1's value is txtSource.Text, args2's value is txtDest.Text. When I press Convert button then the conversion is process.
My application is convert two file.
Please help me!
Best regard!
Thanks!
|
|
|
|
|
Process.Start allows you to pass parameters.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi,
I have a question. Is there any .Net class or method to set or get metadata (Like Autor, Title, Description etc...) information of file (.png, .jpeg files) using C#?
Any idea?
Thanks!
best regard
Adiphe
"...all is simple, but there is always simpler ..."
|
|
|
|
|
Yes, there are classes around that do this. The fotovision sample contains some examples, in VB.NET.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Thanks Christian!
where can i find the fotovision sample please?
best regard
Adiphe
"...all is simple, but there is always simpler ..."
|
|
|
|
|
|
Hi to all!
A short question:
Is it possible, to use an object,list,array or something like that as a database?
So I want to run SQL like queries on my object.
Ex.
I have a list, witch contains Person object (List<person> Persons)
Person class for ex.:
<br />
class Person<br />
{<br />
private int _id;<br />
public int ID<br />
{<br />
get{return _id}<br />
}<br />
private string _name;<br />
public string Name<br />
{<br />
get{return _name}<br />
}<br />
}<br />
I want to run a select for those persons who have id under 10 like this: SELECT * FROM Persons WHERE ID<10
How can I do this?
I try it witd bindingsource, try to add my class as project datasource, but nothing work
Thanks for help.
|
|
|
|