1.in my Winform a make a remote call to the process and ask him to give me the list of all printers installed.
2. show the output in a lisbox for exemple.
We can abstract the question to "how do I get data from PC1 to PC2". The recommendation would be to look into WCF, but any type of exchange-mechanism would do- there's examples on communicating using sockets, but it'd even be possible using simple files.
Are the computers on the same LAN? If yes, I'd go for a simple socket
i would like to execute this code on a remote computer and get the data back to my winform.
Then you will need to write something to do that communication, or use an existing solution
You could also adapt the console-example to suit your needs, hence the link. If that's too much trouble, then you'd have to map a network-drive from the server, and use a batch-file to write the result to a file on that network-share. E.g.;
I am really new to C# .NET and SQL Server, I usually manage to find all my informations thanks to existing posts, but I have to admit I'm actually stuck and a bit lost with all the resources available.
I am actually developing a Windows Forms Application with Visual C# Express 2010 which would use (read/write) data from a SQL Server 2008 Express DB
I have created my DB with SQL Server Management Studio (2008 Express), I understand the instance is named ATLELAG786576\SQLEXPRESS My DB is called 'TEST'
Looking at my DB 'TEST' Properties in SQL Server Management Studio (2008 Express): Under Files, I am (ATLE\bneveux) the owner of the DB
Looking under Security, Logins, Mylogin (ATLE\bneveux) My default DB is 'TEST' Server roles are 'public' + 'sysadmin' User Mapping DB 'TEST' User 'dbo' Default Schema 'dbo'
publicstatic SqlConnection newCon;
publicstaticstring connectionStringTestDb = ConfigurationManager.ConnectionStrings["connectionStringTestDb"].ConnectionString;
publicstatic SqlConnection GetConnection()
newCon = new SqlConnection(connectionStringTestDb);
conn = dbConnection.GetConnection();
//Method insert new in tblEmployees
publicvoid addEmployee(string Id, string Name, string Email)
if (conn.State.ToString() == "Closed")
SqlCommand newCmd = conn.CreateCommand();
newCmd.Connection = conn;
newCmd.CommandType = CommandType.Text;
newCmd.CommandText = "INSERT INTO tblEmployees VALUES ('"+ Id +"','"+ Name +"','"+ Email +"')";
in a form formEmployeeAdd.cs:
publicpartialclass formEmployeeAdd : Form
dbAccess access = new dbAccess();
privatevoid btnInsert_Click(object sender, EventArgs e)
access.addEmployee(txtId.Text, txtName.Text, txtEmail.Text);
MessageBox.Show("Data successfully added");
And here the error message i always get when trying to run this process: System.Data.SqlClient.SqlException (0x80131904): Cannot open database "D:\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\TEST.mdf" requested by the login. The login failed. Login failed for user 'ATLE\bneveux'.
Note that I have never really been able to add my Data Source in Visual C# 2010 Express so I could manage the DB from VS, I always get the following error message: Unable to open the physical file "D:\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\TEST.mdf". Operating system error 32: "32(Le processus ne peut pas accéder au fichier car ce fichier est utilisé par un autre processus.)". An attempt to attach an auto-named database for file D:\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\TEST.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
You're probably doing something wrong. I just tried it and had no trouble at all. Xml is perfectly capable of storing the text and giving it back.
You would need to show us the code you are using to determine what's wrong. Whatever the problem is, Replace isn't the best solution. Even if you think Replace is "good enough" for the particular program you're working on, it is not a good general solution and finding a better one will help you become a better developer.
P.S. What you posted will not produce well-formed XML if the user enters characters that aren't allowed. Try something like:
This read text from text box and ads xml tags, and makes string strContent. Where are this "know how to" read text with only LF? This read simple Text property form text box. Since text box
use CR+LF this read text with CR+LF? So why he wrote that he only "know how to" read only LF? Where is sense in that?
More. Line above text you quoted he wrote
Because this is a paragraph, so the text value of the text box will include characters like: "\r\n" and "\r\n ".
So he wrote that text box have CR+LF, then in next sentence wrote that he only "know how to" read LF and pasted code sample with reading text box with CR+LF chars.
Where is sense in that? There is non.
Obviously is writing some king of app to edits XML content with only LF, and from text box gets CR+LF.
You would get to the same if you would spend on it more than half a minute, think and do not reply with 'you are bad programmer because you like simple solution'
I did, I wrote a whole database table (SQL Server 2008 R2) and Winforms app in an effort to reproduce the "problem". Did you?
I was unable to reproduce the problem, therefore there must be more information that the OP left out.
For instance, he doesn't show how he gets the strContent into and out of the database, that could be where the value gets messed up. Without more information, a proper answer can't be provided.
You are never humble, do you. Who are you to to tell what answer is "proper"? Do you know everything?
If someone is happy with solution do you have to force him to change his mind?
1. Text box returns "\r\n" in content
2. Content must be inserted into xml without "\r"
What is "left out"? That's the problem.
What about solution.
Why I waste my time discussing anything with you, self proclaiming, uber-programmer. Maybe in you world overcomplicating thinks is good thing. Not in mine.
Ah, so that's how you're interpreting it. I interpreted it as the OP wants to store the \r, but for some reason it's getting lost along the way. As I said, I was unable to duplicate the problem. If, as you say, he wants to not store the \r yet get it back again (and I have no idea why that would be), then I would still have better suggestions than Replace.
At any rate, until the OP responds with a clearer explanation of the situation you and I could continue to debate it and neither of us wants that.
Maybe in you world overcomplicating thinks is good thing. Not in mine.
Solving the problem rather than sweeping it under the rug to cause trouble down the line is what I consider a good thing.
If this is just a proof of concept ignore my comment below
If this is to start creating configuration for your application a txt file will work, but is probably not the best option around there. You can use
- ini files (Please don't)
- xml files (better)
- App.config or similar (recommended, certainly if you want machine based settings)
- Database (I usually use this one as much as possible and use an app.config to point to the database)
Note that there is a difference between user settings (eg, language, application options, ...) and system settings (time outs, root paths, database connection strings, ...) You might want to split those.
//How many lines should be loaded?
int NumberOfLines = 15;
//Make our array for each line
string ListLines = new string[NumberOfLines];
//Read the number of lines and put them in the array
for (int i = 1; i < NumberOfLines; i++)
ListLines[i] = tr.ReadLine();
if the title is in number 5 line
this.text = ListLines;
one all the lines are added in the array then you can pick your desired one.
hope this will help you..
I think computer viruses should count as life. I think it says something about human nature that the only form of life we have created so far is purely destructive. We've created life in our own image.
I am using Prism to handle IoC, I can do this in VB.NET:
Dim _regionManager As IRegion
Dim _container As IUnityContainer
Dim mainRegion As IRegion = _regionManager.Regions(RegionNames.MainRegion)
ForEach v As View In mainRegion.Views
I am getting the following eror: non-invocable member ....Regions cannot be used as a method.
When I use this C# conversion:
IRegion mainRegion = _regionManager.Regions(RegionNames.MainRegion);
for each(var v in mainRegion.Views)
Some hints as to why would be very helpfull.
I don't speak Idiot - please talk slowly and clearly
I've been searching for a while now, but the best I was able to do was send bytes of data through my network using a very simple Server program/client program TCP setup in Microsoft Visual Studios 10. I gave the Server an IPAddress and told the client to connect to that specific address.
My end goal is learning how to create a simple multiplayer game using XNA Windows Game.
Any help, information, or direction is greatly appreciated!
yes, i was able to use the socket to send bytes over my network; however, i'm completely lost when it comes to sending bytes over the internet! I've found that link before, but I didn't think it was what I was looking for. I'll look more into it now though, thanks.
Last Visit: 31-Dec-99 19:00 Last Update: 26-May-15 18:01