|
guidoursus,
You want to use C# as a database backend?, why would you want to do that? I dont think i am understanding your question.
Regards,
Gareth.
|
|
|
|
|
The data I need are on an a server in different databases. I have to make several forms, some to see the data of the persons, some other to ad new data about these persons.
GuidoUrsus
|
|
|
|
|
Hi all,
I want to run a console application in C# from visual studio in debug mode (by pressing F5).
Is there a way to enter the arguments thru VS?
Thank you.
"Nothing is lost, Nothing is created, Everything is transformed" Lavoisier
http://wlwilliamsiv.com
|
|
|
|
|
I think you can set commandline arguments in Project settings
fafafa, ringakta icke sådant som bringa ack så naggande högönsklig välmåga å baronens ära.
|
|
|
|
|
There sure is. Take a look at your project's properties under the debug tab (or wherever it is on the version of Visual Studio your using). You'll find a field called Command Line Arguments.
Regards,
Rob Philpott.
|
|
|
|
|
Hi All, I am in the process of re-writing a business application that was originally developed in VB6.
I have decided to seperate the application into tiers and have a Data Access layer, Business Logic layer and business entities. I've writtern some generic classes which are inherited by my business logic and business entities to provide certain basic functionality.
Ultimately my question is regarding unique identifiers for my business entities. If for instance i have a Fleet object which contains vehicle entities and that the vehicle entities have a VehicleID field. This field is used to uniquely identify it in the database. I didn't want to make it a public property because that would allow the user to edit it and upon calling update on the entity, would overrite an incorrect record in the database. I then thought about possibly using the constructor so that when the entities are originally pulled from the database and the instances of the entities are created, the ID field is passed as a parameter and only a property getter exists to read the ID value if required. This also poses problems because if i was to create a new entity i.e Vehicle v = new Vehicle(10) this could pose a problem because a vehicle with an ID of 10 could already exist and could potentially be overwritten in the db.
Since i am the only developer i suppose i could use either of the two methods and just make sure i don't make a silly mistake but i would like to know if it is possible to provide the sort of functionality that offers protection from such mistakes.
Thanks in advance.
|
|
|
|
|
Yeah, typically in these situations you let the database assign the ids of objects, perhaps by using identity columns. Your objects would only be assigned an Id after persisting them to the database. Existing objects are loaded by id, new objects can be created adhoc, but only become 'permanent' with an id after a save to the database.
Nice to see that your thinking this stuff through, you wouldn't believe some of the dire hacked approaches I've seen 'in the field'.
Regards,
Rob Philpott.
|
|
|
|
|
Thanks for the reply. I'm pretty new to C# and would like to 'Do It right'. But i'm still unclear of a good approach.
How else could i get the ID field into the entity without exposing the entity to potential abuse/mistakes. If i use the constructer of the entity when i populate it from the database, that constructor would still be available throughout the program and would allow an instance to be created adhoc along with a potentially invalid ID. I thought about creating a hidden property by setting it's browsable and editor browsable attributes to false but this felt like a hack to me.
|
|
|
|
|
This is tricky in .NET. In C++ you'd provide a method to set the id and only allow this to be called by marking the legitimate thing which can call it as a friend.
The granularity is less in C#, but you can mark the method as internal then it can only get called by other types in your assembly. You can use [assembly:InternalsVisibleTo("OtherAssembly")] to bodge this to allow other assemblies to see your internals. So you could adopt this approach and have your data access layer (which is presumably in a seperate assembly) given this special permission.
Regards,
Rob Philpott.
|
|
|
|
|
I'll give that a go. thanks for your help.
|
|
|
|
|
Hi, I have to view pdf file in widows form .
Can any one help me ?
If you have any solution please mail me at khaleek_ahmad@yahoo.com
Thanks & Regards
Khaleek Ahmad
|
|
|
|
|
Hello Khaleek,
There is 'WebBrowser' control which you can use on Windows application form. You can find it in the
toolbox under All Windows Form. Draw the control on the form. Then you can use the 'Navigate'
property to mention the path of the file you wish to open. For example:
this.webBrowser1.Navigate("c:\\test.pdf");
I hope this will help.
Regards,
Allen
Allen Smith
Software Engineer
ComponentOne LLC
www.componentone.com
|
|
|
|
|
how do i make the comboxitem isselected when i retrived back the data from database?
i tried as below
if reminder is 1 day , the comboxboxitem (reminder1) will be selected..
is this correct?
if (row["reminder"].ToString().Trim() == "1")
{
reminder_1.IsSelected = true ;
}
|
|
|
|
|
Folowing is the code that is written in the console application.
what is the meaning of % displayString.Length
in the folowing line
Console.Write(displayString[counter++ % displayString.Length]);
class Program<br />
{<br />
static int counter = 0;<br />
<br />
static string displayString =<br />
"This string will appear one letter at a time. ";<br />
<br />
static void Main(string[] args)<br />
{<br />
Timer myTimer = new Timer(100);<br />
myTimer.Elapsed += new ElapsedEventHandler(WriteChar);<br />
myTimer.Start();<br />
Console.ReadKey();<br />
}<br />
static void WriteChar(object source, ElapsedEventArgs e)<br />
{<br />
Console.Write(displayString[counter++ % displayString.Length]);<br />
}<br />
}
If you have an apple & I have an apple and we exchange our apples, then each of us will still have only one apple but if you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!
|
|
|
|
|
% is modulus or the remainder you get with integer division. What you're doing here is keeping the index of the array within bounds for any value of count.
Regards,
Rob Philpott.
|
|
|
|
|
How can i prevent user from deleting a file when the file is under use by another process ?
I have an application which creates a directory called (say) "Test" and creates a default "Text.xml" file in it.I dont want user to delete the "Test.xml" when the application is in use. what is the code for it.
Currently ,user can delete the file when application is open.
Please tell me the code for it...
|
|
|
|
|
You can't delete an open file (well you might be able to if you fiddle around with permissions enough) so just keep the file open for the duration of your app.
This code:
[STAThread]
static void Main(string[] args)
{
FileStream fs = File.Open(@"C:\bobbins.txt", FileMode.Open);
Console.ReadLine();
fs.Close();
}
Prevents me from deleting the file bobbins.txt until my console app closes.
Regards,
Rob Philpott.
|
|
|
|
|
Also I think there is a lock method for FileStream. Don't know it's efficiency.
"Legacy code" often differs from its suggested alternative by actually working and scaling.
—Bjarne Stroustrup
modified on Friday, March 14, 2008 7:10 AM
|
|
|
|
|
Ah, not sure about that; never used it, but if so that sounds better!
Regards,
Rob Philpott.
|
|
|
|
|
snoby wrote: How can i prevent user from deleting a file when the file is under use by another process ?
The file cannot be deleted while an application is using it. What is ... well part of Windows. Run an application and try to delete it ... you cant.
Other wise if I am not understanding you correctly, you can open the file for reading and only after the appliation has finished with the file, you can close the file.
something like ...
form onload()
open file for reading
form_onclose()
close file
Hope it helps ...
Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
What if want to be sure that no data is lost? Keeping a file opened could cause all data is lost on crush or immediate shut down.
I suppose that such construct could be used:
open file;
write data which shouldn't get lost;
close the file to save it; (*)
reopen it;
// ...
and so on.
But in could theoretically happen that user opens a file just after (*), before it's opened in the next command. The propability of this is near 0, anyway what to do then?
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
Just holding the file open won't do that. It's when you write data to the file without flushing it, or shut the machine off in the middle of a disk write that you run into this problem.
|
|
|
|
|
I'm using TextWriter to create a .txt file. I'm using TextWriter.WriteLine() to write the string. Suppose my string is very huge say more than 100 characters then the few characters at the end are cut off. How can i determine the maximum no of characters i can store using WriteLine()? so that the remaining characters i can write in the next line?
|
|
|
|
|
Hi,
Just a question ....
What happens when you make use of a StreamWriter ??
Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
I tried StreamWriter but it is the same problem the characters are truncated. Please help
|
|
|
|