|
hi..i am doing a project in c#.net.i want to know how i access web services to my project.my project is news management system,and i want add flash news facility through web services.please help me
|
|
|
|
|
Create a web service or get a external web service and add it to your project through "Add a webreference" option. Or you build your own, deploy it in IIS and add a web reference of that. now you can use it.
Education is not a way to escape poverty — it is a way of fighting it.
|
|
|
|
|
|
I have 2 text files.
input1.txt:
560-005;CORFU_1B;560-005-011
560-005;CORFU_1E;560-005-012
560-005;CORFU_1Z;560-005-013
560-005;CORFU_1H;560-005-014
560-005;SENSE_2B;560-005-021
input2.txt
562-Z21;METAL-ANTHRACITE;562-121-000
562-Z21;METAL-9007;562-221-000
562-Z22;METAL-ANTHRACITE;562-122-000
562-Z22;METAL-9007;562-222-000
public void Conversion()
{
try
{
using (sr1 = new StreamReader("c:\\input1.txt"))
{
using (sr2 = new StreamReader("c:\\input2.txt"))
{
file = new FileStream("c:\\output.txt", FileMode.Create, FileAccess.Write);
sw = new StreamWriter(file);
string line1;
string line2;
while ((line1 = sr1.ReadLine()) != null)
{
string[] temp1 = line1.Split(new char[] { ';' });
while ((line2 = sr2.ReadLine()) != null)
{
string[] temp2 = line2.Split(new char[] { ';' });
string final = temp1[0] + ";" + temp1[1] + ";" + temp1[2] + ";" + temp2[2] + ";" + temp1[2] + "-" + temp2[2];
sw.WriteLine(final);
}
}
}
}
}
finally
{
sr1.Close();
sr2.Close();
sw.Close();
file.Close();
}
}
I have created the above method to do some string management. The problem is that the outer while loops runs only for the first line in input1.txt and I don't know why. It's probably something simple but I can't find the solution.
Thanks...
|
|
|
|
|
Hi,
your code reads each stream once; i.e. for the first line of the first file, the entire content of the second file is read, then everything comes to a halt since sr2 has reached the end-of-stream condition.
if you want to have all combinations of lines from file1 and file2, then you should:
- either open the second file inside the while loop reading file1 (hence reopening it for every line of file1);
- or reposition sr2 at the beginning over and over again.
BTW:
Your try-finally construct will swallow any exception that may occur. I recommend you add catch(Exception exc) {Console.WriteLine(exc.ToString());} to visualize most problems that may (and sooner or later will) occur.
[CORRECTION]Exceptions don't get swallowed by finally blocks, they survive the try-finally construct and will have to be catched at some outer level [/CORRECTION]
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
modified on Tuesday, June 16, 2009 8:39 AM
|
|
|
|
|
Or use ReadAllLines to read each file into a string array and then loop though with nested foreach loops.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Luc Pattyn wrote: Your try-finally construct will swallow any exception that may occur
Are you sure? Since the catch is missing, the finally block will be executed and the exception rethrown, no?
|
|
|
|
|
Hi,
my mistake, you are right, try-finally without catch does not influence exception throwing/catching at all.
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
Thank you guys...
I did what Luc said and it worked.
|
|
|
|
|
Hello to everybody....
I have developed an application in C# which one is intended to interact with a database file. Well, as it is not supposed to be a large and complex database, I chose to work with MS Access. So far so good.....
Now, my application is already developed and the database as well, but the following issue came out to my mind: whether it would be possible a multi-user access to be performed upon the database. The number of users is expected to be up to 10.
How to use same MDB file over LAN network, and performing operation parallely from multiple users.
Any article/hint or clue will be highly appreciated and exceptionally helpful!
regards
|
|
|
|
|
Hum Dum wrote: How to use same MDB file over LAN network
Place the db on a place that is accessible for all the pc's in the network (that use your program).
Then you need to alter you connectionstring so that it points to the path where the db is.
Where it comes to locks and performance, it depends on how you'v written your program.
Access isn't the best solution for a multi user environment. And depending on how you'v written your code it could cause db locks or strange behavior when more than 1 user is altering the same data.
Only testing will tell you that.
|
|
|
|
|
thanks for reply.
Tom Deketelaere wrote: need to alter you connectionstring
can i use open dialog box control, so that user can locate the MDB file for 1st time, then store this path on local pc for next uses.
Is it correct way?
Tom Deketelaere wrote: And depending on how you'v written your code it could cause db locks
I am using DataAdapter, then uploading all data in datasets, datatable, then updating back the changes back to original DB as user updates.
Its very helpful of your if you point out to some article or reading stuff, as i know very little about distributed/client-server environment.
I want to know in detail.
regards
|
|
|
|
|
Hum Dum wrote: can i use open dialog box control, so that user can locate the MDB file for 1st time, then store this path on local pc for next uses.
Is it correct way?
That would be the best way yes.
To store the path you can use the settings file (go to project properties --> tab settings).
As to the db locks and such, if there only be 10 users the changes of something going wrong are small, but like others have said you might want to consider going to a different server (sql-express), performance will be better and possible locks are handled better.
If you are staying with access, you might want to consider creating a service or a small tool to 'repair and compress' the database, since it will grow with every update/insert/delete you do.
I don't know of any articles so can't link to them.
|
|
|
|
|
Further to Tom's reply, if the data layer is seperate to the client, it would be better to have an process running locally to the server that can manage the access to the Access DB. With ~10 users it is unlikely, unless it is for data entry, to hit concurrency problems.
A better solution would be to look at migrating the database to one which supports multiple users.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
thanks for reply.
will you plz point me to some article or website from where i can gain the required knowledge?
about server-client approach i know very little.
|
|
|
|
|
Further to Nagys' reply, it is worth planning for the future. If it is intended for 10 users, then plan for 30! Access is not brilliant at multi-user, and you may find bandwidth problems if the DB gets large (as the query is executed at the local machine, rather than on the server hosting the DB.)
I would sugest a client - server approach would be appropriate - nothing too complex, but have a server app to interface with the DB and keep all unnecessary data off the network. This also allows you to control concurrency issues better than just letting several apps access the same DB directly.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Hi,
i am trying to do a matrix (2X3 cells) in which i want to set each cell to be with different backcolor and text , and to be able to detect a click event on a cell so i could change the cell backcolor and text.
can i do it wuth the TableLayoutPanel control? how?
thanks,
Samy
|
|
|
|
|
samy100 wrote: can i do it wuth the TableLayoutPanel control
Yes.
samy100 wrote: how?
Create your panel, with the rows and columns you want.
Add a label control to each, and set its Dock property to Fill.
Set its TextAlign property to MiddleCenter.
Set each label Click event to the same click handler.
Make your click event look like this:
private void label_Click(object sender, EventArgs e)
{
if (sender is Label)
{
Label lab = sender as Label;
if (lab.BackColor == Color.Red)
{
lab.BackColor = Color.AntiqueWhite;
lab.Text = "Hello";
}
else
{
lab.BackColor = Color.Red;
lab.Text = "Goodbye";
}
}
}
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
We want to open an FTP link in remote desktop machine?
after opening the link we need file information on the FTP link.
How would that happen?
Any help would be appreciated........
Thanks
|
|
|
|
|
do you need to get some files from the remote machine ? if so you could directly put ftp commands in a file and you can run it like,
open machine name
username
password
get a.txt
bye
why are you trying to open a link in the relate machine
Education is not a way to escape poverty — it is a way of fighting it.
modified on Tuesday, June 16, 2009 7:46 AM
|
|
|
|
|
Thanks,
we have requirement to open an FTP link which can only be run in remote machines(any port setting is there perhaps).
|
|
|
|
|
what do you mean by opening a FTP link in remote machine ?
Education is not a way to escape poverty — it is a way of fighting it.
|
|
|
|
|
We have to access a file and that file is on a ftp location and that ftp location can only be accessed by remotely connected server.So the steps that we need to take is as :
1-Remote connection to a server
2-after RMC connect to ftp.
3-check the modified date of a file on ftp location.
I think It calrifies all your doubts.
Thanks,
|
|
|
|
|
As far as I know you can keep a binary or a script on a remote machine which can access the server and ftp the new file to the remote machine.
Education is not a way to escape poverty — it is a way of fighting it.
|
|
|
|
|
Hi,
I'm trying to debug a smallish application which crashes approximately every 10 days with an out of memory exception. Specifically, i've established that the problem lies within a single thread, and I suspect I know which object is causing the problem, but I need to find out when copies of this object are being added and removed from the memory.
If this is not possible, could I perhaps have some general pointers as to when an object is generally added and removed from memory? I realise of course that what is likely happening isn't the application running out of physical memory, but running out of address space, but understanding the problem is getting me no closer to a solution!
Any help would be appreciated,
Thanks,
Nil
|
|
|
|