Nerseus
*Experts*-
Posts
2607 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by Nerseus
-
It sounds like your tables are still fine - you just want a query that has a WHERE clause. Or, are you asking for something else? For example SELECT Customer.*, Account.* FROM Customer INNER JOIN Account ON Customer.CustomerID = Account.CustomerID WHERE Account.AccountName IN ('Company Car', 'Office Supplies', 'Internet Service', 'Movie Rentals') Not knowing what you want returned or in what format, I can't help more. But the above would return all customers and their matching accounts. If you need more help, you'll have to ask a more specific question. I was under the impression your original question was more how to create a Bill table (which you don't need based on your description). If you want one row per customer, then you'll have to fake a new table. For example, if you want one row to have a customer and 4 columns with the "Company Car", "Office Supplies", etc. info then you'll need more advanced code to "flatten" out the data from a row-based format (the Account table) into columns. You could do that with a temp table, or a number of sub-selects or other options. Depending on the size of the database/project, this is what a Data Warehouse is for. A warehouse allows you to flatten out some tables for speeding up reports where a normalized table structure doesn't work as well. -ner
-
You can definitely recurse, but you'll need some kind of limit so you don't retry indefinitely (a bad idea if the SQL is failing because of bad SQL syntax, which would never work). You can enhance the method to take a "count" parameter which is increased on every recursive call or have a static variable, but it's about the same as using a loop. -ner
-
If you want multiple Accounts per Customer, the first two tables give that to you - it's the CustomerID in the Account table that allow that. Make sure you don't have a unique key/constraint on the Account table's CustomerID. That gives you a 1 to 0-to-many join. You would introduce a Bill table with CustomerID and AccountID if you wanted a many to many join, which you said you don't want. -ner
-
Couple of things to try: 1. To alias the columns, make sure you surround the name in brackets: SELECT tempCallRef as [Call], column2 2. If using Crystal reports, I believe you can manually change the column headers after you've done your "binding". The column headers are only defaults. 3. If using a DataSet for binding, most binding grids and maybe reports can read the DataColumn's Caption. The Caption defaults to the FieldName (or maybe Name?) in the DataSet but you can change the Caption. -ner
-
You might also consider using a "known" invalid value to represent null. For example, DateTime.MinValue. Just another option - I've used both object/Variant and the DateTime.MinValue in different pieces of code. The object stuff is more readable, but requires more casting (more coding and slight loss of performance though negligable). The "known" value allows specific type casting (always a DateTime) but might require conversion when going to the DB. Also, eliminates the use of that one value for any real data. I've never had the need to store DateTime.MinValue anywhere as a valid value though. -ner
-
There's no keyword for what you want, but you can do it programmatically fairly simply. For DB calls and webservice calls, you can usually wrap the call in a function that attempts, say, 3 retries. Here's some pseudo-code: Function CallDB(string SQL) int i = 0; do try Make DB Call break; // exits do/while catch i++ while(i < 3) if i == 3 // Error - never got through end if End Function -ner
-
For someone who hates VB so much, you sure do a LOT of work in the language. I know, I know - not your choice. Funny how there isn't much work in Delphi these days :) A twip, as I'm sure you know, is a type of coordinate meant to make screen coordinates easier. It assumed a 15 inch monitor, I believe. There are conversion functions if inches, pixels, or something else suits you. As already mentioned, an event handler is always, always, always just a function. It becomes an event handler not because of the function, but because of the code that calls the function at the right time. As for the flexgrid - it's very, very popular. If you really wanted help, maybe post something like "trying to get flexgrid to programmatically highlight whole row". I'm sure someone has done what you want - if you're nice, maybe they'll share. -ner
-
I see what you mean - only it's a bit more than you describe. Meaning, when you click the start button it does run the code immediately. But, it's not waiting for a second click - it's waiting for any input. If you click anywhere on the form - the title bar, the form itself, etc. - it seems to cancel that click. I didn't test this, but my guess is you could fix this one of two ways (maybe) or definitely one way (hacky). The easiest seems to use the API SendMessage with a LBUTTONUP message (can't remember the constant offhand). This would fake it so it seems like the user clicked and then let go of the mouse. The other possible solution would take more experimenting but would involve overriding WndProc and intercepting clicks in there (maybe in conjuction with the form's KeyPreview set to true). The definite solution is to enable a timer in the button's click and then have the timer call the function to do the loop. I call it hacky, but it would work because it uncouples the events from the procedural looping code. An interesting problem - one I'd look into if I had more time. -ner
-
You can add events in code if you want. If you want them recognized in the Designer, add them in the InitializeComponent method. If you type something like: this.textBox1.Click += You can then press Tab twice to add the rest of the line and the default function itself. It's not quite as "easy" as VB6, but I still like it. I mostly use the designer to add events as there aren't generally that many to add (maybe 2 dozen on one form and that's only a one time thing). As with VB, you can double click a control in the designer to add a default event (button's get a click event, textbox gets TextChanged, etc.). -ner
-
Chris Bangle's Ideas - Creative? or too dramatic
Nerseus replied to ThePentiumGuy's topic in Water Cooler
Here's my take: Had a '78 Chevette, thought it was the best car ever. Totalled it. Got a '74 Buick Lesabre, thought it was the best car ever. It threw a rod. Got a '75 Buick Lesabre, thought it was the best car ever. It threw a rod. Got a '78 (I think) AMC Eagle - it was junk, but I loved it (drove it through 3 feet of water for 200 yards). After the 3rd clutch replacement, I junked it. Drove my parent's car for awhile and loved it, totalled it one day (finally, not my fault!) Bought my first new car: '95 Dodge Neon (first year Neon was made). thought it was the best car ever. It broke a lot while under warranty, eventually sold it. Bought my next new car - 2001 Honda Civic. Still driving it. Thought it was the best car ever until I drove my wife's 2004 Accord. Thought that car was great til I drove my boss's Acura. There will always be something better - whether looks or not. The cost generally goes up for the extra features, though. At some point you have to make a decision. I'm sure a BMW is a great car - made well and handles well. If you can afford $32,000 for an entry level car, you've got more money than me. If you want to spend another 5 to 10 grand, go mercedes or jaguar. More money? I'm sure there are better cars available... What's the point? As usual, I have none that I can think of. Just Random Thoughts after all :) -ner -
I would think your time would definitely be better spent on almost anything other than learning to program in assembly. It wouldn't hurt to learn the basics of assembly - it helped me understand what's really going on with memory, especially when I later learned C and C++. It's also come in useful on maybe 2 occasions to just read assembly - that 2 occasions in the past 10 or 12 years. I've never had to write assembly, ever, for anything other than college courses and a few tester programs (also in college). I'm not saying assembly isn't used anymore. But it's such a niche language with very limited usage. I've seen it mostly used in certain critical areas of game programming. And you wouldn't write core parts of a game in assembly - you would do analsys when the program is complete (or close) and maybe optimize those areas where hand-tuned assembly might provide a worthwhile gain. -ner
-
Normally, the button would call a function that does the looping. If you want to allow a cancel mid-process, you'll want a form-level variable to handle closing. For example: public class Form1 : System.Windows.Form { private bool bRunning = false; private bool bPaused = false; private void ClickEvent() { bRunning = true; do { if(!bPaused) { // Your processing code here, including progress bar updates } Application.DoEvents(); } while(bRunning); // If needed: // Application.Exit(); } private void Form1_Closing(...) { if(bRunning) { bPaused = true; DialogResult result = MessageBox.Show("Are you sure you want to Cancel?"); if(result == DialogResult.Yes) { bRunning = false; } { e.Cancel = true; bPaused = false; } } } } All typed in here, so no syntax checking etc. Should give you the jist. -ner
-
Suggestion: The thread labelled "Need help detecting end of line when reading a barcode" is a good start. Also, showing us that you've got some code working and what you're having trouble with helps us to help you. My experience with barcodes is that it acts exactly like a keyboard. The application will not know the difference between what's being scanned (or when it started) and what's being typed. Maybe your scanner has some mechanism to indicate the end (send a CHR 0 as the last byte). If not, can you assume anything about what's being scanned? Maybe it's always 10 digits. After your textbox reads in 10 chars, have the code process the click. Something like: // Assume a textbox named txtEntry that's being "read" into private void txtEntry_TextChanged(object sender, System.EventArgs e) { if(txtEntry.Text.Length == 10) { // Assume that after 10 chars, you want to save the data or process some function btnSave.ProcessClick(); } } As PD said, the quality of your post will determine the quality of your response. -ner
-
As a piece of advice: There's virtually no reason to learn/code assembler unless you have a very, very specific need. For example, my old university taught assembly for mainframes because a local company needed assembly language programmers to maintain old apps. assembly is also machine specific. To do anything interesting with assembly, it will probably be OS specific as well. If you want a free compiler, look at nasm. Microsoft and IBM also make compilers, but nasm seems the most popular. -ner
-
How can copy a row from one DataTable to another DataTable?
Nerseus replied to angus234's topic in Database / XML / Reporting
Look at the ImportRow method of the DataTable. -ner -
The biggest use, before formatting became big (HTML and PDF), was for interfaces. That is, transforming data from one XML schema to another. For example, it's easy to get data into XML from a Database - the DataSet's GetXml() does that for you. But many webservice consumers will want the data in a specific XML layout. Imagine a healthcare system in .NET that needs to send some data to other companies (Dr/Provider information, client/patient information, etc.) for processing. The other companies may still be expecting EDI (a semi-standard) or NTS formatted data. -ner
-
To be more exact, you have to talk about a class versus a struct not just "object" which means different things to different people. Also, it's only the data within a class that's passed ByRef. The variable itself can be passed ByRef or ByVal and it does make a difference. For a struct - any value type really - ByVal and ByRef works more the way you'd expect. Here are two threads that talk about it a little more: http://xtremedotnettalk.com/showthread.php?t=78621 http://xtremedotnettalk.com/showthread.php?t=84175 There was a better thread than these two, but my searching isn't what it used to be - I couldn't find it (only tried looking for ByRef). -ner
-
I can't believe anyone who's seen Farenheit 9/11 would vote for Bush, or so I've heard. I haven't seen the movie yet... If you like Nader or the "Red vs. Blue" series, check this out: Real Life vs. Internet. About halfway through there are two sketches about "Talking Politics": real world versus the internet. If you don't know anything about "Red vs. Blue", it's NOT political in any way. I'd say it's about as far from politics as you can get and about as funny as it gets (on the internet). The full link is: http://www.redvsblue.com/home.php -ner
-
Disbeliever! Actually, I remember hearing last year when Valve said they were shooting for end of September. We all know what happened after that. But this time it's Vivendi that's driving the Nov 16 date. I tend to belive the publisher more, since it'll be their butt on the line if it's late. Since the gold master went to Vivendi about a month ago (same as Release Candidate), I trust that all is well. I'd be willing to bet my Cure "Join the Dots" collection on it. That's somewhere between "I'd bet a penny" and "I'd bet my car", but more towards the "I'm pretty sure" and nothing like "I'd bet a million dollars". In the meantime, why not play CS:Source? You can watch the tires roll down the hill, wobble, and tip over. Over shoot big barrels, milk jugs, and more. It's weird how the wooden crates still don't explode though... -ner
-
As for your first question (sorta) - I believe you can only have one DataReader on a connection at a time, if the DataReader is a forward only "firehose" type reader (old terminology). Generally, this type of reader is using the connection the whole time (as you read a record, it's retrieved from the server). These used to be the server-side cursors, because the server (such as SQL Server) would hold all the data in tempdb until the reader asked for it. I'm not sure if that helps or not. Hopefully I'm not making it worse. Now, if you're using webservices... all webservices provide a default asynchronous call. You might look into that if you want to load two chunks of data at the same time. It doesn't require any special threading logic on your part - just two calls instead of one. -ner
-
If you can identify the XSL portion (the XPath to get you to the node that contains the XSL), just grab its text and load it into an xml document for use in the transform. -ner
-
I mostly skimmed these posts - no time to read them all. For those interested, check out this link to Alex De Tocqueville's Democracy In America. While it IS a hard read, it's very inciteful. The most interesting part is that it was written at the time the USA was "born", and from a Frenchman's perspective. It's mostly unbiased - he's no sure whether democracy will work or not. Personally, I think it works as good as anything. It's funny to hear someone talk about power hungry leaders in a democracy... as if there aren't power hungry leaders in any government (dictatorship anyone?). I don't mind if no one reads this - it would be only fair :) -ner
-
Not release Half Life 2 in the near future? In a bit over 2 weeks: Nov 16. -ner
-
Bill Clinton was in office for 2 full terms - that's the limit for a US president. He didn't get kicked or leavered (?) out. I didn't read any more of your post as that first part made you sound like an ***. Just my opinion. -ner
-
Maybe compare r.Item("CallListDesc") to System.DBNull.Value? I don't think you can use .ToString() on a column that contains DBNull (the equivalent of the database's null). -ner