|
I would store them in a database, but that's just me.
|
|
|
|
|
pls which starts the execution of a C # application?
thanks.
|
|
|
|
|
what do you want to ask, please explain in detail.
|
|
|
|
|
Execution of C# application starts from method Main().
|
|
|
|
|
|
Hey guys,
I have a question regarding the components which have a built in datasourse, like datagrid, combo box, ...
I dunno whether my windows application I'm working on, is gonna be run on a single computer or on a server and in a network, so how should I define the connection string, clearly I cannot go for code-less method (am I right ? ), so how should I tackle this problem ?
this is basically my general question for my whole application as well and Would be greatful if u helped me out!
regrads,
K
|
|
|
|
|
Never hard-code connection strings - put them in the application config file. That way the DB can move without code changes.
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
I'm aware of that, and thats what I'm doing but still the servername differs from one computer to another, well one solution I thought of was to install their SQL server manually set the server name to a specific name which is in my application ... but I wanted to see if there were other possible ways !
regards
|
|
|
|
|
Include the servername in the connection string - it is part of it. Then configure SQL server as part of the install procedure (do a test connect and if it fails get them to enter it manually) then save it in the app.config file.
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
I prefer to have a system-wide, non-application-specific configuration file that lists the databases available to the system.
Such a file can be stored in the Application Data directory for the user or all users -- so all users can have the same settings, or each user can have his own.
And I don't store actual connection strings; I store the information required to cobble one up for the requested database engine.
Here's an older version:
<DATABASES>
<CT TYPE="SQLSERVER" SERVER="LOCALHOST\SQLEXPRESS" NAME="CoconutTelegraph" />
<DTER TYPE="SQLSERVER" SERVER="LOCALHOST\SQLEXPRESS" NAME="DTER" />
<DDLTEST TYPE="SQLSERVER" SERVER="LOCALHOST\SQLEXPRESS" NAME="DDLTEST" />
<FIREBIRD TYPE="FIREBIRD" SERVER="LOCALHOST" NAME="C:\Program Files\Firebird\examples\empbuild\employee.fdb" USERNAME="SYSDBA" PASSWORD="masterkey" />
<MPG TYPE="SQLSERVER" SERVER="LOCALHOST\SQLEXPRESS" NAME="MPG" />
<MR TYPE="SQLSERVER" SERVER="LOCALHOST\SQLEXPRESS" NAME="MusicLibrary" />
<RUBBISH TYPE="SQLSERVER" SERVER="LOCALHOST\SQLEXPRESS" NAME="Rubbish" />
<SA TYPE="SQLSERVER" SERVER="LOCALHOST\SQLEXPRESS" NAME="VersionControl" />
<WORDSEARCH TYPE="ACCESS" NAME="C:\projects\wordsearch\bin\release\WordSearch.MDB" PASSWORD=":badger:" USERNAME="admin" USERPASSWORD="" />
</DATABASES>
And here's a version I'm working with this week:
<Databases>
<Junk Provider="SqlServer" Parameters=".\SQLEXPRESS,Junk" />
</Databases>
This allows the application to be more database agnostic -- it doesn't need to know which database engine is in use.
|
|
|
|
|
thanx for the response but I'm afraid I didn't get it exactly, could u elaborate more on how to use this piece of code and where to use it ?
thanx alot!
|
|
|
|
|
After read the Essential C#, I am still puzzled why C# has the event keyword.
The Delegate is similiar with the function pointer in C/C++ and can make the function of programming needed. So I think that the event is unwanted.
right?
modified on Wednesday, July 7, 2010 11:33 AM
|
|
|
|
|
yu-jian wrote: So I think that the event is unwanted.
right?
Wrong. Sorry, but event is a specialist form of multicast delegate - to achieve this specialism, the event keyword was necessary.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
You're wrong, and that's probably why you're not working on the C# team at Microsoft.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
Yes, but... the event keyword allows special handling of the multicast delegate:
0) Only the defining class can raise/call/execute the event.
1) All other classes are required to use the += and -= operators.
You are welcome to use non-event multicast delegates in your code if you like. Come back and let us know how it goes.
|
|
|
|
|
Your answer is good. I know event is useful,
Thanks very much.
|
|
|
|
|
I am working with .net application. I have few informations in string. Now i would like to put this string into html tags. Lets say i have array of names and i would like to write them down in html paragraph. How could i do this in c# code?
|
|
|
|
|
You can use response.write() function to do that.
string htmltodisp="here is my string to display in paragraph";
Response.Write("<p>" + htmltodisp + "</p>");
Hope this will help!
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
It depends how you want to format the data. Suppose for instance that you want each name in a paragraph, a quick and dirty hack to do this would be to use something like:
StringBuilder sb = new StringBuilder();
foreach(string name in names)
{
sb.AppendFormat("<p>{0}</p>", name);
} Alternatively you could look at the HtmlTextWriter[^] class to do the job properly.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Pete O'Hanlon wrote: Alternatively you could look at the HtmlTextWriter[^] class to do the job properly.
I think he's better off writing it the frist way. What benefit does the HtmlTextWriter have? I diodn't see any, myself.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
I wasn't sure if he was working in an ASP.NET environment. If he is, and he's developing a custom control (again - unsure, so I've gone for the safe case here) then the HtmlTextWriter (and children such as the XhtmlTextWriter) are a good fit.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
I would use WebUtility.HtmlEncode from System.NET library.
It provides a correct encoding of '<','>' and '&' ,...
Your html code would have bugs, if your string contains one of the chars and you don't encode them.
You can decorate the converted string with html tags.
|
|
|
|
|
Hey Guys
I'm using the RegEx to do some pattern matching, but I'm after finding one of 2 specific strings.
At the moment I'm using Regex reg1 = new Regex("FIRST[ ]+STRING");Regex reg2 = new Regex("SECOND[ ]+STRING");
Is there a way I could get the Regular Expression to say match exact string A OR exact string B in the same statement? (eg Regex exp = new Regex("ThisString or ThisString");
Thank you in advance
oooo, the Jedi's will feel this one....
|
|
|
|
|
Regex exp = new Regex("(ThisString)|(ThatString)");
Will do it nicely.
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
Thats it???
So simple. I'm kicking myself now. Thank you.
oooo, the Jedi's will feel this one....
|
|
|
|