|
A good while back I started a program to read csv files, classify the lines to separate the chaff from the wheat, then convert the text fields to proper types and save the records to a remote SQL Server database. As usual, I did it half in the bag, late at night after very long days at work, that being the only time I have available. I had to drop it for a couple of months, but I'm now back into it and trying to figure out what I was doing. Predictably, it's a mess - spaghetti code, for lack of a better term. It works, that part that I managed to finish back then, but the major hurdle lies ahead and I'm refactoring the monster before I begin again. But I digress...
I had no trouble using the StreamReader to read the data, and at your collective suggestion, implemented ugly, nasty little Regexes to classify the text lines into keepers and crap. I asked about creating a new database on the remote SQL Server instance, and after being told that it can't be done, did it anyway. All that works great, jumbled mishmash though it is. What's stumping me is this:
On first run, I want to create the database and save all the neccesary connection information in the AppConfig file so I won't have to enter it manually. I can't figure out how to do that, despite searching MSDN for articles on the subject. I believe that there exists a whole class devoted to manipulating the AppConfig file, but I'm stumped and have little time available to search through all the irrelevant links MSDN returns. Can someone give me a quick clue? I know this is trivial stuff, as every program that accesses a database uses it, but I'm not having much luck with it for some reason.
Thanks a bunch in advance. If I didn't have this crowd to assist with the sticky bits, I'd probably quit programming at all, even as a hobby - it so easily becomes incredibly frustrating. I'm unspeakably grateful...
Will Rogers never met me.
|
|
|
|
|
Is the ConnectionStringSettings class[^] what you are looking for?
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
|
|
|
|
|
Excellent! Thanks a bunch!
Will Rogers never met me.
|
|
|
|
|
|
Thanks!
The previous answer adressed the specific problem, and yours the more general one. I appreciate it!
Will Rogers never met me.
|
|
|
|
|
Roger Wright wrote: as every program that accesses a database uses it
Mine don't.
Roger Wright wrote: the sticky bits
Most developers here don't have to worry about those; just we in the desert.
|
|
|
|
|
PIEBALDconsult wrote: we in the desert.
It wouldn't be such a problem if they'd let us wear our birthday suits at work. A little breeze goes a long way.
OT - Are you getting the frigid winds there, too? Brrrrr....
Will Rogers never met me.
|
|
|
|
|
Roger Wright wrote: wear our birthday suits at work
Way, way, way, TMI...
Now I have to get that image out of my mind. Naked developers.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
|
|
|
|
|
Fear not - I'm not a developer. Imagine, instead, naked engineers!
Will Rogers never met me.
|
|
|
|
|
Sounds like a Dilbert episode...
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
|
|
|
|
|
Roger Wright wrote: frigid winds
Yes.
|
|
|
|
|
Hi there !
I start to developing a hotel managment system C# + MySQL database.
I have to make some like graph schedule (it's only for view)
It should looks like:
for example on some month...
is 3 persons in room2 from 2 to sixth day of month and the color of this line...
1 2 3 4 5 6 7.... 31 (days for months)
room1
room2 3 3 3 3 3
room3
it will download the data_from and data_to of reservation some of specified room, the type of residence which is declarated in specified color and then at last how many persons are in this room
and now it will draw lines of a given color from the day-to-date and in the middle of this line in each row of the color line the number of people in this room
I wonder how to do it ... First what control should i use dg, lvor ..?
And how to declare this all months with days...
Plz help how to start it?
|
|
|
|
|
I'd use a DataGrid and to keep it simple stupid have a class that represents the room and every day of the month. Then write some code which returns a collection of the class. There would be a lot smarter ways to approach this but sometimes keeping it simple is the most maintainable.
You may also look at your database structure because sometime guests may stay in one room for 2 nights and a luxury room for 1 night. You may want to store this data night by night and not from-to date.
Good luck with it. Micros Fidelio are one of the most fierce competitors your every likely to bump into.
Architecture is extensible, code is minimal.
|
|
|
|
|
i will have a data_from, data_to in, number_of_people register table the colors will declare in other one i think and the room in other and buildings in other :/
In C# i will have .cs files which represents entities and mapping classes for this entities .
But could u write some example how it could be? I Will really happy I heard somewhere that lv will be better than dg...
BTW if I will use Flunet NHibernate and LINQ NH + mapping should I make in My MySQL Server relations on Entities (i mean in MySQL Server) or just make entities and PK's but in VS Entities .cs files and mapping it will be enough ?:
for example:
public class ClientMap : ClassMap<Client>
{
public ClientMap()
{
Id(x => x.Id).Column("client_id");
Map(x => x.FirstName).Column("imie");
Map(x => x.LastName).Column("nazwisko");
Map(x => x.Created).Column("utworzony").Not.Nullable();
Map(x => x.Updated).Column("aktualizacja");
Map(x => x.Deleted).Column("Usuniety");
HasMany(x => x.Rooms)
.Access.Property()
.Cascade.All()
.LazyLoad()
.KeyColumn("client_id");
Table("klient");
}}
modified on Tuesday, February 1, 2011 6:45 PM
|
|
|
|
|
I don't have any examples at hand but there are a few open source PMS systems out there so do a search and see how they have approached the problem. It's a fundamental requirement for both PMS and CRS systems.
Regards
Rob
Architecture is extensible, code is minimal.
|
|
|
|
|
in my application once a client connected i run the following code
byte[] buffer = new byte[512];
while (soc.Connected)
{
try
{
soc.Receive(buffer);
string encodedstr = Encoding.UTF8.GetString(buffer);
this.Invoke(update, new object[] { encodedstr });
buffer.Initialize();
}
catch (Exception)
{
if ((soc != null) && (soc.Connected))
{
soc.Disconnect(false);
}
}
}
but when the client disconnected by closing or accidentally the server runs infinite loop with the
last content sent by the client. so my textbox infinitely append the last data to it's content.
so i want to know if ther is any other better way of receiving data from client continuously to solve this problem.
|
|
|
|
|
That is how TCP/IP works.
The only sure way to validate if someone is on the other end is by sending something, sometimes quite a bit of something.
The way servers commonly solve the problem is that they require clients to send them data during a given time period. If the client fails to send anything then the server disconnects.
Another way is to explicitly send a do nothing message to which the other end must respond within a given time period. If they don't respond then disconnect (obviously disconnect as well if there is a delivery failure.)
|
|
|
|
|
None of the information in your post is correct as far as using a socket class is concerned and applies only to writing your own TCP/IP stack.
|
|
|
|
|
|
|
Ennis Ray Lynch, Jr. wrote: See Page 45[^]
I suggest that you make it more explicit how you think I am wrong.
Or perhaps you could provide a code sample of a listening socket that will detect that the other end is gone when the power plug is pulled on it.
|
|
|
|
|
I suggest you read the documentation for Windows Sockets and the RFC and use them as guides instead of Google searches yielding results that are questions and answers from non-definitive sources. When you post an answer as an Authority you have some responsibility for accuracy. Using TCP/IP and then manually sending keep alive messages is a waste of the protocol.
|
|
|
|
|
Ennis Ray Lynch, Jr. wrote: I suggest you read the documentation for Windows Sockets and the RFC and use them as guides instead of Google searches yielding results that are questions and answers from non-definitive sources. When you post an answer as an Authority you have some responsibility for accuracy.
You are incorrect in the intent of my posting.
I know how sockets work having worked with them in C#, Java and C++.
I was citing references to back up what I was saying rather than just restating what I said already - which is what you are doing. Feel free to provide some specific references to make your point. Or cite something specific from the RFC.
I have in fact read the RFC and the C# documentation.
Again...please provide a specific comment on exactly how you think all or part of my response was incorrect.
Ennis Ray Lynch, Jr. wrote: Using TCP/IP and then manually sending keep alive messages is a waste of the protocol.
This statement indicates that you do not know how TCP/IP works.
Again feel free to provide code and a specific scenario that allows a listener to detect when the other end is terminated by a pulled plug. Feel free to provide the code in C#, C++, Java or even Perl.
Although I suppose it is possible that you did not understand why I was suggesting a keep alive. Perhaps that is where your confusion lies.
|
|
|
|
|
prasadbuddhika wrote: while (soc.Connected)
I doubt that is going to serve the purpose that you think it is.
That doesn't validate the connection. All it tells you is that at some time in the past that it worked.
The following are probably the general run time conditions that one faces with sockets.
1. It fails to connect at all. Reasons: Wrong address, port, firewall rules or the server is down.
2. It runs
3. The server disconnects gracefully. Receive() will return zero.
4. The server takes too long. Reason: Server is locked up.
5. The server never responds. Reasons: Someone kicked out the power plug or the firewall dropped the connection.
Notice that in 4/5 no exception occurs. You can get an exception to occur by setting a time out value. That tells you that it hasn't sent data but not why.
|
|
|
|
|
Hi all
how to do function like Console.write() but without using Console.write() and with different name.
I want to say how to create a print function without using Console.write() and name it as you like.
I hear that i can do it by overloading or overriding or anything else .. i don't know.
Thank's
-*-*-*-*-*-*-*-*-*
To Be Or Not To Be
(KARFER)
-*-*-*-*-*-*-*-*-*
modified on Tuesday, February 1, 2011 11:50 AM
|
|
|
|