did you try col1 = dr["col1"].ToString().Trim(); col2 = dr["col2"].ToString().Trim(); col3 = dr["col3"].ToString().Trim(); if( dr["col4"] == DBNull.Value ) { // Do Stuff recordsSelected = dt.Select("col2 = " + "'" + col2 + "'" + " And col1 = " + "'" + col1 + "'" + " And col3 = " + "'" + col3+ "'" + " And col4 = ''"); } else { col4 = dr ["col4"].ToString().Trim(); recordsSelected = dt.Select("col2 = " + "'" + col2 + "'" + " And col1 = " + "'" + col1 + "'" + " col3 = " + "'" + col3 + "'" + " And col4 = " + "'" + col4 + "'"); }
Mark Greenwood
Posts
-
DataTable.Select("Column is null") very slow -
Calling a method from a Lib to ExeYou would have to delcare a delagate in the Library code - inform the Library of the Exe method which implements that delegate - i.e. have a method in the library which takes an instance of the Library delegate and then call that delegate from the library at the appropriate time....
-
how to check if a given xml file is well formed or not?Easiest way might be just to open it in an XmlDocument - it will fail if it's not well formed I think....
-
Show proccess windowOn my wrong computer right now so don't have access to MSDN - but try WM_RESTOREWINDOW(or whatever it's called) or WM_MAXIMIZE - essentially Show Window is used when the window is hidden (different from minimized), and set focus just set's the focus, it won't restore it from it's minimized position.
-
import list view in a text fileDo you mean how can I export items from a ListView into a textfile or How do you import items from a testfile and place them in a listview?
-
"Danger meter" control?Check out http://www.codeproject.com/cs/system/CpuUsage.asp[^] This is a control which monitors CPU usage and shows a progress bar accordignly - like the Task Manager thing. I'm sure you can adapt the code to be able to monitor whatever you need - changing the color of the control depending on a particular level should be pretty easy....
-
Setting the "Address" of INternet Explorer through C#Better than that you can actually do the following
Process pr = new Process(); pr.StartInfo = new ProcessStartInfo("http://www.google.com"); pr.Start();
If IE is set up to handle HTTP items then it will actually open and automatically direct you to google.... -
ScrollProperties.Value needs to be set twice?Not sure why - but I just opened up System.Windows.Forms in reflector and looked at the Value property - the set_value has the following code;-
public void set_Value(int value) { if (this.value != value) { if ((value < this.minimum) || (value > this.maximum)) { throw new ArgumentOutOfRangeException("Value", SR.GetString("InvalidBoundArgument", new object[] { "Value", value.ToString(CultureInfo.CurrentCulture), "'minimum'", "'maximum'" })); } this.value = value; this.UpdateScrollInfo(); this.parent.SetDisplayFromScrollProps(this.HorizontalDisplayPosition, this.VerticalDisplayPosition); } }
If you follow the UpdateScrollInfo call - it ends up calling into the Windows API and calling SetScrollInfo on the control... If you follow SetDisplayFromScrollProps call it ends up calling a function called ApplyScrollbarChanges - which is one of the longest MS functions I have seen in a while - I'd look at the logic of that function and see if that is doing something weird.... Be interested to know if you crack the issue - my belief is that the first call fails (or appears to do nothing) - also maybe it's something simple like the control needs to be updated to reflect the change and ultimately calling the Value set property a second time causes that... Mark -
Should I use objects or XMLHmmmm, Interesting issue. I know we have had similiar issues in the past = Can I ask how the clients get the update file in the first place ? Is it from some Web Service or do they just download it etc? I'm also presuming that the Actual application itself which opens this XML file will know that it is possible that it will run SQL on potentially multiple different databases (i.e. ones with different schemas and potentially different versions). If that is the case then why not actaully send down a ZIP file or Cabinet file with several XML files. One primary XML file with essentially a manifest set of nodes - each one referencing one of the other XML files in the zip/cab, seperated by Version/Schema. For example the primary XML file might look something like this... It would then be up to the app itself to work out which version of client database and which schema (or whatever criteria you need) and then check this against the manifest XML file and then load in the relevant SQL xml file and then run the SQL contained within it. Whilst it may seem inefficient to ship all the files to every client, once it's zipped or compiled into a cabinet file the actual file will be pretty small and you also enjoy the benefit of keeping the update logic seperate for each schema/database type. Mark
-
How to create Bitmapped Context Menu in Windows ExplorerJust so we're all on the same page here, Are you asking how you add an icon to a menu WITHIN your application ? or Are you asking how you add a menu item with an icon to the windows shell (i.e. Something that appears when a user right clicks a file in explorer for example)? [Link] Is a very simple example of this - just search in google (or even here) for "Windows Shell menu c#" or terms like that Mark
-
XML in C#Use this control http://www.codeproject.com/cs/miscctrl/Siepe_XmlTreeView.asp[^] You just throw an XmlDocument at it and it shows all the nodes as a tree style control I've used it - it has editing etc built in Mark.
-
Make a widget (like the old konfabulator) in C#A couple of days ago someone posted this article http://www.codeproject.com/useritems/AlphaForm.asp[^] It might assist you in what you are attempting to do - it's a start anyway... Mark.
-
access insert instruction problemHmmm ok that is strange, One thing that can occue on a SQL database is that case sensitivity can be on which means that a table called Image will not be found if you look for a table called image - no idea if that applies to an access database - but I guess it's worth a try?
-
access insert instruction problemThats's not the problem as far as I can see - sorry I'm struggling a bit with your english to understand what you are saying, but I think your issue is that the connection is fine - it's what you are trying to do with it is wrong. You can't use an INSERT (SQL) statement as a SelectCommand on the adapter and you can't use the Fill method on the adapter to call the InsertCommand - you have to use the Update method instead. Perhaps you can put up the error and maybe that might cast some more light - but it looks as though it's just an issue with using the adapter incorrectly...
-
access insert instruction problemWell I was right in the first instance - if you look at the constructor for the OleDbDataAdapter - the command query which you pass in is for the SELECT command ONLY - so it's not going to take care of what you are trying to achieve here - you need to create an InsertCommand and then call update - that should fix it (maybe!)
-
access insert instruction problemWhat's happening when you run it? If your getting an error what is it? I think part of the problem is using the adapter.Fill method - I'm pretty sure that you need to use the Update method and also I'm not sure yoy sepcify a command text for the dataset - I thought you used an InsertCommand and calling update called the appropriate Commands with the change rows in the Dataset, and likewise the appropriate Update and Delete commands - been a while though so I could be wrong there - I'll look it up and let you know.....
-
Is software installed on pc?Windows 2003 server is a little trickey since there are multiple types (Gold, Small Business Server etc) and multiple languages... However 2003 Gold - English can be determined by detecting Windows Language is '9' Windows Version is Major Version '5', Minor Version '2', Service Pack Major '1' and Service Pack Minor '0' Internet Information Services 5.0 - English Windows Language = '9' system32\inetsrv\iisui.dll version >= '5' system32\inetsrv\iisui.dll < '5.1' system32\inetsrv\coadmin.dll >= '5' system32\inetsrv\coadmin.dll < '5.1' Internet Information Services 5.1 - English Windows Language = '9' Reg key 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\IISAdmin' Version < 5.2 Reg Key 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\IISAdmin' Version >= 5.1 Internet Information Services 6.0 - English Windows Language = '9' Reg key 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\IISAdmin' Version < 6.1 Reg Key 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\IISAdmin' Version >= 6.0 I'll have to check SQL Server 2005.....
-
Encrypting the passwordFor What It's Worth = FWIW Use SHA256 - that's pretty strong - we use it in my company (note I'm not saying WHICH company) Mark
-
.Net Drag and DropYou will need to load the file in as a FileInfo and then look at the attributes to see if it's a directory or not...
FileInfo f = new FileInfo(strFileName); if ((f.Attributes & FileAttributes.Directory) == FileAttributes.Directory) { // Delete it } else { // Ignore it - or whatever }
-
newbie aspx.vb questionThe files will be contained in the solution which created the DLL - if you don't have access to them - download REFLECTOR and open the DLL files with that - you can at least see what the code behind looks like even if you don't have access to the original files. Mark.