Jump to content
Xtreme .Net Talk

Nerseus

*Experts*
  • Posts

    2607
  • Joined

  • Last visited

Everything posted by Nerseus

  1. Do you have the values stored someplace else that you can use? Otherwise I'm not sure how you could NOT hard code it? Here's an alternate way to load some data: DataRow row = sementesDT.NewRow(); row["CodSemente"] = 0; row["CodTipo"] = 0; row["Semente"] = "SubCat0-Cat0"; sementesDT.Rows.Add(row); Now, picture that in a loop where you can change each value. You can, of course, use your code to do that in a loop. If you have the SubCat-Cat data in another format (a file, database, enum, etc.) then let us know. -ners
  2. If the VB "Is" operator is like C#'s "is", then that only compares types. Keep in mind that I'm a VB.NET noob :) If I may summarize for those coming in late to the thread: the topic of whether or not it's a good idea to overload Equals or == comes down to two opinions: when you see a comparison of two reference types, would you naturally assume you're comparing the references or the values. In easy terms: do the variables point to the exact same chunk-o-memory or do they both reference the same "value" such as Customer # 123. I wouldn't presume to say that one is wrong versus the other as long as everyone on the team knows the standard. I would strongly suggest NOT mixing the two (some reference types compare by reference, some reference types compare by value) as you'll easily get confused. I would be curious to see how each of you feel's about this subject in a year or so - if anyone has changed their mind. I wish there was a way to flag it to be "reopened" in a year :) -ner
  3. I've never tried this, but I found this article: http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/ext/tutorials/button.asp I did a google search to find it. I searched for the following (including the double quotes): "internet explorer" toolbar sdk -nerseus
  4. Make sure the file is not readonly and that it's not open in Access itself. Otherwise, I can't think of why you'd get that error. -ner
  5. I went digging into Reflector and found out a few things... Boolean.Parse() will be slightly faster than Convert.ToBoolean because the current implementation of Convert.ToBoolean(String) calls Boolean.Parse(). Of note: Convert.ToBoolean(String) will return a "default" of false if you pass in null (Nothing in VB). A call to Boolean.Parse(null) will throw an exception. If you know 100% that the string will always be "true" or "false" (and not "True" or "1" or "-1" or...), I'd find it Ok to go with the direct compare. I actually had to write my own "IsBoolean(string)" function to handle some "odd" values, coming from a 3rd party. It had to interpret true/false, yes/no, 1/0, and a bunch of other values. I didn't really have much to add, but I had already typed this all in... :) -ner
  6. Are all of these in the same solution? If not, I don't see the problem as you just have to build each one, one at a time (as long as you close solution A before loading B or C). If they're in the same solution I'd set each project as a Project Reference, if possible - that would be the ideal solution. If they're in the same solution you can also use the Project->Project Dependencies dialog to mark each dependecy to make sure they get built in the right order. I don't have much experience there as setting a project as a Project Reference does this for you and works for me. -ner
  7. I'd use an XmlDocument to load the string. You can use XPath syntax to select out the elements you want. The two most useful methods are SelectNodes and SelectSingleNode. Below is a code snippet. I've attached the whole C# project as well. XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(txtXML.Text); XmlNode usersname = xmlDoc.SelectSingleNode("/TestRoot/usersname"); if (usersname != null) { txtusersname.Text = usersname.InnerText; } XmlNode surname = xmlDoc.SelectSingleNode("/TestRoot/surname"); if (surname != null) { txtsurname.Text = surname.InnerText; } I hope you understand that to do anything with XML, you must have valid XML. Your original sample string isn't valid - probably not cut and paste, but make sure the string IS valid XML. For example, your string had a comma between elements which isn't allowed. It also had an element "usersname" with a closing element of "username" - hopefully just a typo. If you just have a bunch of separate elements surrounded by commas, then it's CRITICAL that you tell us that. As Cags asked, a real sample string would help us to help you much better - you can fake the values if you want, but the formatting of the elements and such is very important. -ner XMLTest.zip
  8. I love sample code, so here goes: private void btnWissen_Click(object sender, EventArgs e) { ClearTextBoxes(this); } private void ClearTextBoxes(Control parent) { foreach (Control childControl in parent.Controls) { TextBox txt = childControl as TextBox; if (txt != null) { txt.Text = string.Empty; } else { ClearTextBoxes(childControl); } } } Untested, but hopefully it works. I was tempted to optimize a bit and check whether I needed to call ClearTextBoxes(childControl) at all, but figured I'd save that for later if needed. The way it is now, it may call a function and get out right after doing the foreach - you're only saving the push/pop on the stack for a function call and I *hate* thinking about performance at the expense of readability, if the performance doesn't really make much difference. -ner
  9. In my opinion, an == check on a reference type should always mean the same thing - am I pointing at the exact same object. If I want to see if two separate instances of a Customer class represent the same customer (say, defined by a CustomerNumber field) then I'd compare on CustomerNumber or add a more suitable method. For Value types, if I'm going to compare them, I would definitely override == and Equals for performance reasons. -ner
  10. Whoa, Nellies! Funny Code was the topic - someone got sidetracked. Let me sum it up: if you like operator overloading, use it. If you don't, don't. If you overload Equals on a reference type (class), I don't care - just don't come work for me :) -ner
  11. Best website idea, EVER, for a DB programmer: http://www.connectionstrings.com/ -ner
  12. I'd post this as a separate issue, so it can get the attention it deserves. I'd mention quickly that Microsoft highly recommends that the SQL Server and Web servers stay separate - and I'd take that advice. SQL takes up a lot of memory, disk and CPU. Webservers are cheap, comparatively, and easier to scale out if needed. You normally only want one SQL Server box - but a big one. -ner
  13. And I assume you want to "return hoeveelheid;" instead of "return 10;" -ner
  14. When I have columns that have a time along with the date and I need a query to filter by a day, that usually means that: If filter date = 1/3/2006 then records with a date of 1/3/2006 should be included regardless of time. I usually use the following approach: Get your compare variable to have only a date (strip off the time) Set the compare variable to one day GREATER than what you want to include Use a "<" check instead of "<=" For your sample, that means using something like: DECLARE @FilterDate datetime -- Set the @FilterDate to be 29 days in the past, minus any time portion -- The varchar convert strips off the time while the outside convert puts it back to date/time -- The outside convert isn't necessary as SQL will convert the varchar into a datetime automatically SET @FilterDate = CONVERT(datetime, CONVERT(varchar, DATEADD(d, -29, getdate()), 101)) -- Add an extra day so an "inclusive" check will work easier SET FilterDate = DATEADD(d, 1, @FilterDate) SELECT ... FROM ... WHERE EntryDate < @FilterDate You could also shortcut that into the following although I prefer to be verbose in the code to make it more readable 6 months later: SET @FilterDate = CONVERT(datetime, CONVERT(varchar, DATEADD(d, -29, getdate()), 101)) -- Add an extra day so an "inclusive" check will work easier SET FilterDate = DATEADD(d, 1, @FilterDate) SELECT ... FROM ... WHERE EntryDate < CONVERT(datetime, CONVERT(varchar, DATEADD(d, -28, @FilterDate), 101)) In the second example I inlined the code and subtracted 28 instead of 29 to save the extra "one more day" check. Here the extra CONVERT back to datetime is necessary - if you don't use it, the SQL analyzer will try to CONVERT the column to a varchar and hurt performance. You can test in query analyzer by using the command "set statistics profile on". I hate fudging hard-code numbers like 29 for 28 to make the code "leaner". If the business rule says "include records that are 29 days or older" then I want the code to have a "29" somewhere - just makes things easier later on. -ner
  15. If this is SQL server I'd do something like this: DECLARE @FilterDate datetime SET @FilterDate = DATEADD(d, -29, getdate()) SELECT ... FROM ... WHERE EntryDate <= @FilterDate That may need some tweaks, in case EntryDate has a time stored in the column. I may be off on the -29 - you may need to subtract 30 or 28, depending on how you code the "EntryDate <= @FilterDate" - maybe use "<" instead of "<=". -ner
  16. I can't think of any direct way to do it. I know you can't put print statements in there. You also won't see the value of variables when using SQL Profiler. You could modify the function to write values to a table and look at the results after. You could also cut and past the function into Query Analyzer and look at the values there - not as a function, but executing each line one at a time. If you have the time, you could investigate setting up SQL Server to allow stepping through code. I've done it once, a long time ago, to step through a stored proc one line at a time. I don't know if you can step into functions though. -ner
  17. If that's all of your code (nothing missing), then I don't see where you initilize strSizeArray. Just like in VB6, you'll have to set the dimensions of the array. I think VB.NET support ReDim, though I think it's generally preferred to set the array once or use another structure such as an ArrayList. Here's an example that initializes the array. Some elements will go unused (and will remain null/Nothing): Dim ctrl As Control, lbl As Control Dim iCtrl, i As Integer Dim strSizeArray() As String = New String(Panel1.Controls.Count) For iCtrl = 0 To Panel1.Controls.Count - 1 ctrl = Panel1.Controls(iCtrl) If ctrl.GetType Is GetType(System.Windows.Forms.TextBox) Then strSizeArray(iCtrl) = (CType(ctrl, TextBox).Text) End If Next The changed line is where I initialized strSizeArray. My VB.NET is scratchy at best, so hopefully that's the right syntax. -ner
  18. I found a link for the 2003 posters, that may help find the 2005 posters: http://msdn.microsoft.com/vstudio/previous/2003/posters/ -ner
  19. Yep, I read the help more and see there's no option to set a default for an existing column that would update the data. Assuming you've already got the column in the table but want to change to not null, do the mass update before altering the table/column: UPDATE chronology SET oper_id = 0 WHERE oper_id IS NULL GO -- The GO is optional alter table chronology alter column oper_id numeric(10,0) not null -ner
  20. Your syntax is close, but a bit off. At least, it's off if you're using SQL Server: alter table chronology alter column oper_id numeric(10,0) not null DEFAULT 0 At least, that's the syntax when using "add" column, not sure if you can set a default when altering a column. I would think so, but not positive. If not, you can always do a mass update followed by an alter that sets the column to NOT NULL. -ner
  21. I wouldn't use Left without checking if InStrRev returned 0. If you pass it a filename like "MyText" then your code will throw an exception. I'd use Marble's suggestion. -ner
  22. The only thing to really worry about is where you put the uploaded files - make sure they're not accessible from the outside, including the webserver. You could rename the file upon upload, if you wanted, but I don't see a point. If your IT department is looking for an arguement to let you do this, point out that it's just as safe as using FTP to let someone upload a file. If you're providing a web interface that is just letting them upload files, I'd consider opening up FTP. Normally I'd pick FTP if I were going to use a watcher component (like FileSystemWatcher). If I wanted the user to upload something and get something back in the same shot, I'd use a webservice or webpage. You can always ask them what they think might happen by letting someone upload a file to a secured folder (not accessible through the website). It's their job to tell you why, specifically, that would be a problem - what security risk it poses. If they say "well, I'm not sure if it would be Ok or not" then I'd suggest they find out. That's their job, not yours :) -ner
  23. What database are you using? In SQL Server, I'd use: ALTER TABLE chronology ALTER COLUMN rec_tmstmp Timestamp NULL The syntax is basically "ALTER COLUMN" and then just explain how you want the column to be, including the type and NULLability. -ner
  24. If you saved a diagram in SQL Server, you can go there. Relationships are really just foreign key constraints. There's nothing built into SQL Server (that I know of) that will show this visually, automatically, other than the designer. But, you would have had to create the relationship through there for it to show up. -ner
  25. I'm trying to find some help on the video game "Trackmania Sunrise". If you're not familiar, it's a great little racing game with an arcade feel. You can't go onto the next track until you beat the previous. There's one we're stuck on (me and my son) called "Goal!". I've tried googling but can't find anything to help. I also tried gamefaqs.com but they didn't have any help. The game's website even has community links, but I couldn't find where any of the sites have help. Although it's a racing game, there's a mode called "Platform" which more of a puzzle. We're totally stuck! He's only 4 and yet he's beat almost every level by himself. But this one he can't get past and I can't figure it out either. If anyone has any info on the game, or knows of another website that lists Game FAQs/walkthroughs/etc., I'd appreciate the help. -ner
×
×
  • Create New...