|
I'm not sure why you're removing the brackets and 'dbo' from SQL. It could open you up to syntax errors, especially since you don't account for the context whatsoever in these sort of find/replace methods. Plus, I remember reading somewhere that stating 'dbo' will improve lookup performance
But whatever...just throwing that out there as a word of caution.
|
|
|
|
|
This one is more concise and more efficient since it doesn't create unnecessary temporary string instances.
public string StripString(string statementString)
{
string[] keywords = { "[dbo].", "[", "]" };
StringBuilder result = new StringBuilder(statementString);
foreach (string keyword in keywords) result.Replace(keyword, string.Empty);
return result.ToString();
} Now, let me ask you a question. It appears you're trying to parse a connection string - is that what you're trying to do? Are you aware there's already a class in the .NET framework that parses a connection string and give you back the interesting pieces of information? That would be OdbcConnection; pass a connection string in the constructor and you'll have a connection object containing all the properties of the connection string.
|
|
|
|
|
string s = "this is a test";
s.Replace("test", "");
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi, all replies may lead to damaged sentences such as "Nuclear s damaged the conants inines",
and basically ignore the subject line.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Actually, i think a couple of the replies inlcuded a space after the word test, so "test ". That would only ruin words ending in test.
And besides, if you do it the way i said originally (though of course, i had forgotten about string.replace) you can remove " test "
with spaces either side. And then when you re-build the string, add the spaces back in.
My current favourite word is: Waffle
Cheese is still good though.
|
|
|
|
|
Words are not necessarily surrounded by spaces, there could be punctuation marks too.
This contest holds two "test" words for you to test.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Yar, stupid punctuation, ruined the english language.
I concede to your brilliance.
My current favourite word is: Waffle
Cheese is still good though.
|
|
|
|
|
Hi:
I am looking for a way to assure that only one instance of a WinForm application can be run on a local area network, how should I go about this?
I'm not up to speed with Sockets or UDP communications, so don't really know where to start.
---
Regards,
Martin.
|
|
|
|
|
i think the easyest way is to create a dummy file somewhere on the network (accessable to everybody)
when your app starts.
and delete when app closes.
in startup of your app, check for existens of that file (File.Exists)
Hope this helps
Kaine
|
|
|
|
|
Although of course, evil people could find an delete the file, then run the form when theyre not supposed to!
Depends on your circumstances though. This is definitely a good idea though.
My current favourite word is: Waffle
Cheese is still good though.
|
|
|
|
|
Hmm. I found this topic: http://www.thescripts.com/forum/thread253568.html[^]
Doesn't give much info, but from what i can see you can get remote processes by using:
Process.GetProcesses("remote pc name");
and that you need to have remote access enabled on the rmeote machine, and maybe some other stuff. You might not need to use sockets at all, although they are rather quite simple to use.
So, you'd have to check the processes of each machine individually, and then run your form if you don't find an instance of your form anywhere.
My current favourite word is: Waffle
Cheese is still good though.
|
|
|
|
|
Hmm, I was thinking more along the lines of a Broadcast or Multicast message and reply workaround.
The created file solution might be a quick & dirty solution though...
---
Regards,
Martin.
|
|
|
|
|
MartinHart wrote: The created file solution
Make sure you (a) create the file if it doesn't already exist and (b) keep it open for exclusive access as long as the app is running.
/ravi
|
|
|
|
|
Good Morning All,
First off, this forum has helped me a great deal with my endeavors of understanding C# better. I utilize the archives and searches extensively and have more times than not found the answer I needed right away.
This time however, I need some help directly. I am creating an application where by I am writing a config file in XML (thanks to a posting here), and one of the elements I need is a directory. I have found and am utilizing the OpenFileDialogue but this Dialogue Box will not allow me to select a directory only. Is there another object that will allow the user to select a directory.
I don't want the user to type in the directory, as you can imagine, just using the Dialogue Box would aleviate users anticipations.
Any help would be greatly appreciated.
|
|
|
|
|
There is another object that does exactly that: FolderBrowserDialog
Hooray!
|
|
|
|
|
HIP HIP HOORAY.
Thanks Undefeated. Made my day!
|
|
|
|
|
Hello
So here's what I'm trying to do: I have Visual Studio 2003 and I have a text (PDF format). I want to print the text. So, I managed to start acrobat reader in silent mode and print the document, but now I want to print multiple documents. How do I do this? Do I have to kill acrobat reader every time? Do I need to use a delay before I kill the process? How long should this delay be?
|
|
|
|
|
Have you tried Aspose.Pdf library? I think it can help you.
|
|
|
|
|
Well... no offense, but I'm looking for something less expensive (and I mean no money at all ). I just want some ideas on how to do this...
|
|
|
|
|
theheartcollector wrote: but I'm looking for something less expensive
Isn't the COM interface free?
|
|
|
|
|
Well... All I can see on their site are demo versions and shareware Can you please provide a link or smth?
|
|
|
|
|
|
Aham... Sorry I'm just starting to learn stuff...
|
|
|
|
|
Hello,
I dynamically add multiple controls to a form from Sourcecode and I want that the Events which are fired from these controls are handled in new Threads. How can I accomplish this?
One way would be I start an own Thread in each of the EventHandlers.
Is there another way to do this?
TIA,
Patrick
|
|
|
|
|
Easiest way to do this would probably have the events fire on the normal thread, but once you receive them, simply start a new thread that does the actual work. (edit: as you already mentioned )
Another possibility is call BeginInvoke on the event when you raise it.
|
|
|
|