Nerseus
*Experts*-
Posts
2607 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by Nerseus
-
First, I moved the thread "rant" to a private area - that's where it should have started. If JoeMamma requests, I can PM him the text so that he can post it on a blog or something more appropriate. It was not a programming related rant and was a bit inappropriate, so it had to go. About the moderators, leaders, etc... what's the real concern? Are you concerned there's not enough help going on? Not enough answers? Too many "dumb" posts? Too many threads in the wrong forums? Do you just want to be a leader/moderator/whatever yourself? Maybe just not enough "presence"? Kicking inactive members doesn't appear to be "policy" - there are many members (non leaders, etc.) that don't get kicked either. As mentioned, Admins don't necessarily need to post. Their job is more to handle the administrative duties - but who knows? There's no real job description for this stuff :) Personally, I don't post as much because most of the posts are already answered by the time I log in, or, people ask questions way out of their league. For example, a seemingly innocent question like "How do I pass a value to my form" can be answered two ways: the quick and dirty answer with a code snippet, or the question and answer of what they're really trying to do which requires way more time than anyone cares to give (the helper or the helpee). I like to answer the easy questions and the ones where I don't know the answer but feel I should - that's when I get to learn something, too. -nerseus
-
You don't have to use SqlParameter objects, but in your example I definitely would. Your problem, however, is probably because OutJudgements is a string column and you're not putting the value in single quotes. Try this: ' ... sqlcommand.CommandText = "UPDATE ClientInfo SET OutJudgements = '" & judgement.Replace("'", "''") & "' WHERE LeadID = " & intLeadid ' ... Two things I changed: 1. I put single quotes around the value in judgement (they're embedded in the CommandText string - look next to each side of the double quotes). 2. Added Replace to the judgement variable. This replace will double up the single quotes. Without that, you may allow SQL injection to get in your code. By using parameters you won't have to worry about that. -ner
-
I'm not sure what your end goal is, but if you just want the generic code to get a list of Pupils into a collection so that you can loop through then try the following. Paste this over Class1 in a new console project: using System; using System.Xml; namespace XmlTest { class Class1 { [sTAThread] static void Main(string[] args) { string s = string.Empty; s += "<ADTfile>"; s += " <Message>"; s += " <Header>"; s += " <DocumentName>A File</DocumentName>"; s += " <ATversion>2.3</ATversion>"; s += " </Header>"; s += " </Message>"; s += " <Pupils>"; s += " <Pupil>"; s += " <UPN>F938870105001</UPN>"; s += " </Pupil>"; s += " <Pupil>"; s += " <UPN>ABC</UPN>"; s += " </Pupil>"; s += " <Pupil>"; s += " <UPN>123</UPN>"; s += " </Pupil>"; s += " </Pupils>"; s += "</ADTfile>"; XmlDocument xml = new XmlDocument(); xml.LoadXml(s); XmlNodeList pupils = xml.SelectNodes("/ADTfile/Pupils/Pupil/UPN"); foreach(XmlNode pupil in pupils) { System.Diagnostics.Debug.WriteLine(pupil.InnerText); } } } } The key bit is the XmlNodeList and the XPath expression "/ADTfile/Pupils/Pupil/UPN". Also, for generic "stuff" you want to format, use <code> and </code> but use square brackets. I used "cs" in square brackets for C#, you can use "VB" in square brackets for VB.NET. -ner
-
I don't know enough about Access to know if you can modify the date format and let SQL queries work with that specified format. I think that you must surround your date values with the pound sign (#) for it to work. My original sample modified: ' Assumes you have two existing DateTime variables that you want to use. ' I called them Date1 and Date2 Dim Date1 As DateTime Dim Date2 As DateTime Dim strDVDate1 As String Dim strDVDate2 As String strDVDate1 = Date1.ToString("MM/dd/yyyy") strDVDate2 = Date2.ToString("MM/dd/yyyy") strNewSQLStatement = "SELECT * From IssueHistory WHERE (" & _ strSelectedSearchTypeDate1 & " between #" & strDVDate1 & "# And #" & strDVDate2 & "#) and (" & _ strSelectedSearchTypeDate2 & " between #" & strDVDate1 & "# And #" & strDVDate2 & "#)" I also had used strDVDate1 far too many times :) If this doesn't work, show us what your SQL string is (strNewSQLStatement above) so we can help solve the problem. Also, try pasting the query you're building directly into Access's query builder to see if it works. If all else fails, zip up the DB and let us take a look. -ner
-
Small update to kejpa's example. You can check the documentation, but SQL Server will usually want dates in a specific format. You're using Day/Month/Year but SQL will usually want Month/Day/Year (USA format). Are you converting a real DateTime value into a string and putting that in strDVDate1 and strDVDate2? If so, I'd do the ToString on the dates: ' Assumes you have two existing DateTime variables that you want to use. ' I called them Date1 and Date2 Dim Date1 As DateTime Dim Date2 As DateTime Dim strDVDate1 As String Dim strDVDate2 As String strDVDate1 = Date1.ToString("MM/dd/yyyy") strDVDate2 = Date2.ToString("MM/dd/yyyy") strNewSQLStatement = "SELECT * From IssueHistory WHERE (" & _ strDVDate1 & " between '" & strDVDate1 & "' And '" & strDVDate2 & "') and (" & _ strDVDate1 & " between '" & strDVDate1 & "' And '" & strDVDate2 & "')" If you just have two strings, you'll have to manually parse them into the correct format or let the DateTime type do it for you. The following code doesn't do any error handling to assure that strDVDate1 and strDVDate2 are valid dates - but it should. ' Assume you strDVDate1 and strDVDate2 defined Dim Date1 As DateTime Dim Date2 As DateTime ' Clone the current DateTimeFormat so we can make changes ' Not sure how to use DirectCast - I'm C# ' I'm trying to cast Clone(), which returns object, into DateTimeFormatInfo ' Hopefully I'm using DirectCast right DateTimeFormatInfo dateTimeInfo = DirectCast(DateTimeFormatInfo.CurrentInfo.Clone(), DateTimeFormatInfo) ' Change the ShortDatePattern, which controls the format ' that DateTime.Parse looks at dateTimeInfo.ShortDatePattern = "dd/MM/yyyy" Date1 = DateTime.Parse(strDVDate1, dateTimeInfo); Date2 = DateTime.Parse(strDVDate2, dateTimeInfo); ' Now you can use the code in the first example to use Date1 and Date2 with their ToString methods. With either of these methods, you don't have to worry about SQL injection. SQL injection can't occur above because the only dynamic portion of the string is the Date, which you're controlling using DateTime types. If you were to use strings directly, then you'd have to worry about SQL injection and double up your single quotes. If you need help there, just search the forums or ask away. -ner
-
I didn't see a question...? Just bragging, or looking for help? Do you need help with the SQL, or building the string, or making the DB call with ADO.NET? Or...? -ner
-
If it works for you, I'd probably use Sleep - not sure what you're doing every 10 minutes though, so it's hard to give good advice. You don't need the API to sleep, it's exposed for you: System.Threading.Thread.Sleep(TimeSpan.FromMinutes(10.0)) There's an overload to pass in milliseconds if that's more your thing. -ner
-
In WinForms you have a TreeView control. I'm not sure if you have a similar control for the web. Is that what you mean? -ner
-
I'm a bit confused - wasn't your question asking for an article or book, and didn't you just provide a link to a book? Or did you mean to JUST ask for articles similar to that book (but free)? -nerseus
-
I've never worked with DataDynamics. But, if you have proof that their product has a memory leak and you let them know, I would bet they'd provide a fix. Is it possible that you're using their component in some way, but forgetting to call some method when you're done? Even if you're not positive that their code has the memory leak, you could show them some sample code and ask for advice. I've used DevExpress and they were VERY responsive to bugfixes (and there were many - but that was about two years ago) as long as we were able to provide code sample to illustrate the problem. Before you send anything off, make sure you have someone else read it and see if they have any questions - if they do, then DataDynamics will likely have the same questions and they may be less likely to respond. -ner
-
You can also scan your PC for free with TrendMicro's software: http://housecall.trendmicro.com/ Before you say "Wow. . . 'Free' means $50 bux a year." wait! The software to monitor costs money, but to scan is free. I bought McAfee from Costco for around $20 for one year. That was worth it to me. I turn most of it off and scan manually for the most part. If I ever download something to install/run then I turn it all on to get a little more protection. -ner
-
Try downloading the new Visual Studio beta as well (or an Express version) - they do full forward/reverse engineering with UML models, all built right into VS. -ner
-
Is this for curiosity, or for a "real" reason? I wouldn't count on the two being equal even if you compile and rename the DLL and compile again - I've seen that produce two different binaries. Why? No idea... but it happens. -ner
-
You can open a dll in Visual Studio - it will show you an resources embedded inside (icons, pictures, etc.). Just use File->Open. If this is a .NET dll and you want to see the code, open it in Reflector. If this is a .NET dll and you want to use the libraries inside, simply add a reference to the DLL through Visual Studio (expand the project in the Solution Explorer and right click on References). If this is a COM dll, you can add a reference to it like above (project references). Visual Studio will create a wrapper object for you, to use the COM object with .NET. If this is a standard C-style dll, you're in trouble as you have to write the PInvoke code yourself to define the exposed functions and get all the datatypes right. If this is a standard DLL, then someone may be able to help. If it's some 3rd party DLL, you may be OOL. If you want something else, you'll have to be more clear. Vagueness is the enemy! -nerse
-
@PlayKid, Maybe you could show us some code snippets of what you're doing? You describe Form2 referencing a variable on Form1 and I'm curious how you've set this up - it will get you a better answer if we know the full picture of what you're doing. Include anything you may have tried, whether it worked or not, as that may help us understand as well. -ner
-
System.IndexOutOfRangeException
Nerseus replied to mfriedenthal's topic in Database / XML / Reporting
You can set a breakpoint at the top to step through and see which line has the problem. It's likely the following line, since you mentioned adding the Status column to the query: If drResults("Status") Then The error line "System.Data.Common.FieldNameLookup.GetOrdinal(String fieldName)" is saying that it's trying to find a column by name and can't find it. That means the code certainly thinks a column isn't there. I'd check that you really are getting back the Status column (run the query directly through whatever tool you use). -ner -
If you simply want to have a dynamic table name, you'll have to use dynamic SQL. In your case, you'll have to piece together the string from something like: CREATE PROC Test (@TableName varchar(50)) AS DECLARE @sql varchar(8000) SET @sql = ' SELECT * FROM ' + REPLACE(@TableName, '''', '''''') + ' WHERE ... ' Three things: 1. Yes, you can put the single quotes like that and then write your SQL as if it were "real" sql and not dynamic. 2. The REPLACE is to double up any singlequotes - shouldn't be an issue since this is a tablename, but NEVER trust a param coming in that's used in dynamic sql. 3. In this sample, you can't use parameters since your "param" is a table. Otherwise you could use a system proc to compile the dynamic sql and use variables. That's useful when you have variables coming in that affect a WHERE clause - then you don't have to worry about SQL injection. -ner edited to change the sql tags to code - there are no sql tags, d'oh!
-
A primary key should be made up of the unique field(s) in a table - the one "key" that can be used to identify a single row. If you have an IDENTITY column or AutoNumber column, then that will always be unique in the table and will usually be the PrimaryKey - but doesn't have to be. As a "key", it should also be the column that holds the value that you want to use in other tables - in those other tables it's the Foreign Key. You MIGHT have a column for SSN in a customer table - if you want to ensure that the SSN is unique. But if you don't want the put the SSN in child tables (like an Address table) then you wouldn't make that your PrimaryKey. An index is something different - it's a set of pointers to rows to speed up retrieval only. They slow down performance on INSERTs and UPDATEs since the index needs to be kept in sync. Often times (and it's the default behavior in many DB's) the PrimaryKey will be set up as an index or even a clustered index. The DB is being smart and assuming that by making something a PrimaryKey, you'll be joining on that column and that usually means you want an index. -ner
-
I did a quick test - I created a new ClassLibrary with one class that implements IList, compiled, and looked at it. It, too, shows ": IList, ICollection, IEnumerable" so that must be how .NET sees it. That kinda makes sense, as far as reflection goes - if you query a class that implements IList and IList implements ICollection, it stands to reason that querying the class through reflection will show both. -nerseus
-
I actually toyed around with the JoinView class - it's free code from MS, in VB.NET. I converted to C# and got it working fairly well, but haven't used it much. It allows creating a DataView like object called a JoinView that joins two tables into one - then you could filter across both tables. It's the equivalent of having a "SELECT table1.*, table2.* FROM table1 INNER JOIN table2 ON...". You can have expression columns from a child table - the syntax is something like: ds.Tables["Employee"].Columns["TerritoryID"].Expression = "child.TerritoryID"; That's from memory, so it may not be right. If you have multiple relationships you can do something like "child(EmployeeEmployeeTerritory).TerritoryID", where EmployeeEmployeeTerritory is the name of the relationship. My luck with expression column wasn't that good. They worked well 99% of the time, but failed when you wanted to do HasChanges() or GetChanges() - they both want to build a NEW dataset (I guess) that only includes tables that had changes. If that was the parent table (Employee) but not a child table, then this would throw an exception because of the "child" expression column. I had to implement a scheme to remove expression columns temporarily and then reapply them when I was done - not too hard, but became tedious to remember and not very performant (it was generic code to loop through all tables/columns). Good luck! -nerseus
-
I've generally built up my filter expression manually and then applied the filter using the "IN (...)". This would only work if the filter column (expression or not) is in your table you want to filter on - I can't tell from your description if that's the case or not. If I hear you, you've got a many to many relationship (EmployeeTerritory being the join table). If your DataSet has a way to get the TerritoryID in the Employee DataTable (maybe an expression column), then you want to build up a string of TerritoryID's, something like: DataRow[] rows = ds.Tables["Employee"].Select("TerritoryID IN (1, 3, 7)"); If you need help building up the "IN (...)" string, I can help. If you don't have the TerritoryID in the employee table then you'll have to find a better way to do it. Here's what I would do in that case (and have done, in production code): 1. Get a list of TerritoryID's as above, but use it to filter on the EmployeeTerritory table: 2. Looping through the EmployeeTerritory records in step 1, get a list of EmployeeID's. 3. Use the list of Employee ID's in step 2 to filter the Employee table. If you want a code example, let me know. -ner
-
You have to implement all 3 interfaces if you inherit from IList, as IList is based on the others. -ner
-
You don't really need abstract on a constructor - it's always overridable (and you never need the word override on the constructor in an inheriting class). It's a special case. -nerseus
-
Don't forget that school starts for many today - the numbers on the forums usually goes up when people are back in school. -ner
-
If everyone in your group agrees to it, you can just use "\t", as Joe sorta had embedded in one of his samples. I'd only do that if everyone knows and understands what \t is - if your group thinks that's too obscure, then don't use it. I often use \n in strings for newline if they're embedded. I'll use Environment.NewLine for piecing strings together. For example: string s = "You are about to delete your whole Database and format the hard drive.\n\nAre you sure?" string s2 = "Bob" + Environment.NewLine; s2 += "The" + Environment.NewLine; s2 += "Builder"; Of course, I'd probably use StringBuilder in place of s2, but I don't want to type that out right now... -ner