Jump to content
Xtreme .Net Talk

PlausiblyDamp

Administrators
  • Posts

    7016
  • Joined

  • Last visited

Everything posted by PlausiblyDamp

  1. I've been caught out by thinking too hard myself in the past, sometimes it's just easier to try it and handle the errors that are raised rather than check for all the possible error cases first. As a caveat though - exceptions can be a bit expensive in performance terms - if there is going to be lots of file IO and a high percentage will fail then an alternate method may be better.
  2. You just run the installer .Net 1.1 or .Net 2.0 It shouldn't make a difference if the server is single or multi processor
  3. Technically you are just detecting if the file can be opened or not - security, network issues etc would all cause your function to report the file is locked... Also you need to be aware of checking if a file is accesible and then trying to open it as on a multi-tasking OS like windows something could happen to the file inbetween you checking and then opening it.
  4. IIRC a column has a HeaderCell property - can't you do something like... dataGridView1.Columns[1].HeaderCell.Style //access it's properties from here That may not be exact as I don't have .Net 2005 handy at the moment but it does ring a bell.
  5. You don't seem to have a way to hook the keyboard select with the menu strip anymore - mouse events can be done with the MouseEnter / MouseHover. Also if you have a tooltip control on a form you can associate a tooltip with a menu strip item, might be easier; plus the information is displayed closer to the mouse pointer / where the user is probably looking on screen anyway.
  6. Dim FromTime As Date = DateTime.Now executeROApproval() Dim ToTime As Date = DateTime.Now Dim ts As TimeSpan = ToTime.Subtract(FromTime) Dim DifferenceInMilliseconds As Double = ts.TotalMilliseconds
  7. The code Cags posted will work fine for creating an array of textboxes - it might help if you show us how you are using this code in respect to your form as there is no reason why you would need to type out all 80+ textboxes (and many, many reasons why you shouldn't).
  8. You would need to recurse through the sub folders, search these forums and you'll find some examples of how to do it.
  9. In that case you might want to convert the string to a decimal.
  10. Firstly there is no need to catch and throw the exception if you are doing nothing with it - just don't bother catching it and it will bubble up the exception handler chain till it is handled. Putting lots of code of the form Try 'do stuff Catch ex as exception throw ex end try Is almost the same as 'do stuff the main differences being the first case loses the stack trace and will cause additional overheads while the second one maintains the stack trace correctly and doesn't have the same associated overheads.. Secondly catching Exception is generally a bad idea as it means you are willing to deal with any and all errors regardless of what they are; often it is better to just trap the specific errors you know how to deal with. In your case te only exception you are throwing is a SecurityException so only catch that type - if other exceptions get thrown then at least you are nor sweeping problems under the carpet. Thirdly throwing an exception from a constructor is a big no-no (either explicitly or implicitly) as it leaves the system in a potentially confused state. i.e. object o = new should always leave o pointing to a valid object - if you throw an exception then this doesn't happen and therefore goes against the recomended approach. Try removing the throw from the constructor and see if the error goes away. If so you might want to re-engineer your code to use a shared Create method on the class to instantiate instances instead of using the constructor.
  11. That's because the function you just created expects you to pass in a second parameter - put VAL in there and it will use the variable as a parameter for the query.
  12. System.IO.Directory.GetFiles("c:\temp", "*.pdf") should do the trick, although permissions may need to be adjusted to allow the web application access to the folder itself.
  13. Stored procedures are not a magic wand when it comes to performance - a badly written stored proc (i.e. returns too much data etc.) will still be a performance hit. If the underlying DB is badly designed or tuned (too much / little indexing done, poor indexing, over / under normalised) will also impact performance. Often deadlocks are a sign of a database design issue - better indexing, locking or knowing how to avoid (or at least limit) them through better SQL coding would help here. Caching is only useful when the data is frequently accessed and changes rarely - caching should only be implemented if there is a proper performance monitoring / testing policy in place anyway - otherwise how do you know if it is working better or not?
  14. You need to pass the VAL string into the query, if you are using the 2005 table adapter designer (and it looks like you are) then you can use a wizard to add a query to the adapter - give it your parameterised SQL as the source and it will generate a wrapper method that will allow you to pass the parameter in.
  15. Exceptions will be passed up until they are caught by an appropriate excpetion handler, if there is no suitable handler then it will crash. Also you do not need to throw ex here - if you do not handle the exception it will automatically be passed up to the 1st suitable handler.
  16. What do you mean when you say it falls over on that line? If you step through the code is it catching the exception? If so the only thing you are doing is throwing it again...
  17. http://www.xtremedotnettalk.com/showthread.php?t=83092 might be worth a read first, if you are still having problems then let us know.
  18. The data reader also exposes a NextResult method this will advance you to then 2nd result set.
  19. System.IO.Directory.GetFiles(...) will return all the files in a given directory that match a wildcard.
  20. The point of an OpenFileDialog is to allow the user to browse for a file to open, if you want the user to just select a folder then you could use the FolderBrowser instead.
  21. Each item is a DataRowView object based on the underlying data source - you need to cast it to a DataRowView and then you can access it's properties directly.
  22. Arrays start at 0 so you shouldn't have any problems there. You could probably also simplify a lot of this code by using built in .Net functionality, a few quick changes you might want to consider are. If Len(pString) < Length Then For i = 1 To Length - Len(pString) pString = pString & " " Next i End If could be replaced with pString = pString.PadRight(Length) The whole chunk For i = Len(pString) To 0 Step -1 Dim NewString As String NewString = Right(pString, Len(pString) - i) strSplitString(i) = Left(NewString, 1) Next i can be replaced by declaring Dim strSplitString() As Char = pString.ToCharArray() or just using pString.ToCharArray() directly in the remaining code also code like bw.Seek(Offset + Incre, SeekOrigin.Begin) bw.Write(Hex(Incre2)) is not needed as bw.Write will automatically advance the position in the file based on the value you are writing. Dim Results() As Byte Dim ResText() As String 'snipped ReDim Results(Length) ReDim ResText(Length) could be declared as just Dim Results(Length) As Byte Dim ResText(Length) As String
  23. Arrays can be statically declared under .Net which would remove the need for the InitTable Method completely. Dim Table() As String = {"~", "\n", "", "\i", ""} 'etc. just carry on to the end of the array This would also save runtime overheads as the current implementation seems to be recreating the exact same array into the exact same variable each time the function is run... It may help if you could explain what the two functions are actually attempting to achieve as there may be a much simpler way in .Net.
  24. You can always get the current form by using the ActiveForm property of the MDI container. Also you can get the current control via the ActiveControl property of a form.
  25. System.Threading.Thread.Sleep(200) should do the trick
×
×
  • Create New...