Jump to content
Xtreme .Net Talk

Derek Stone

*Gurus*
  • Posts

    1910
  • Joined

  • Last visited

Everything posted by Derek Stone

  1. No, however you can launch the process that contains the form using [msdn]System.Diagnostics.Process[/msdn].Start().
  2. Be nice divil; we're all friends here.
  3. I'd read in far more than one line at a time if the file even had a chance of exceeding a few hundred kilobytes, which you said it will. In other words I wouldn't use ReadToEnd() or ReadLine(), since they are slower than frozen molasses. Additionally, using ReadToEnd() (or ReadLine() on a file with few or no carriage returns/line feeds) would cause a huge memory allocation to take place, spiking a very small application up to 150MB+ if a 30MB file was loaded. The following is an alternative that searches an entire 60MB file in under a second (in my tests): Dim bufferSize As Integer = 102400 Dim file As StreamReader = New StreamReader(New FileStream("D:\Desktop\Log.txt", _ FileMode.Open, FileAccess.Read, FileShare.Read), _ System.Text.Encoding.Unicode, False, bufferSize) Dim wordToFind As String = "Pencil" Dim buffer(bufferSize * 2) As Char, counter As Integer While file.Peek >= 0 counter += 1 file.Read(buffer, bufferSize, bufferSize) Dim content As String = New String(buffer) Dim location As Integer = content.IndexOf(wordToFind, bufferSize - wordToFind.Length) If location > 0 Then 'MessageBox.Show("Text found at: " _ '& ((counter - 1) * bufferSize + (location - bufferSize)).ToString(), _ 'Application.ProductName) 'Exit While End If Array.Copy(buffer, bufferSize, buffer, 0, bufferSize) End While file.Close()
  4. Please read my post in our very informative FAQ. Also, in regards to Mono-- it is not an IDE, and therefore not what you are looking for.
  5. Call SetAuthCookie() prior to using Response.Redirect.
  6. Not that I'm aware of. For $50/hour there could be however. ;)
  7. I'd like to see a reporting forum as well, although I wouldn't want it limited to just Crystal Reports. That way I could ignore all the threads started there. :)
  8. Remove any XML document declares <?xml version="1.0" encoding="UTF-8"?> Remove xml:lang, xmlns and any other XML+XHTML attribute Change the document type to HTML 4.x Revert to minimized attributes <td nowrap="nowrap"> <!-- changes to --> <td nowrap> Open empty elements <br /> <!-- changes to --> <br>
  9. Microsoft.VisualBasic.Compatibility is installed with Visual Studio .NET and must be redistributed manually if you do choose to use it. It is not part of the .NET Framework Runtime Redistributable, meaning that your server probably doesn't have it installed (thank God; keep it that way).
  10. The only problem with using Regular Expressions in a case such as this would be speed issues. You'd have to perform tests to ensure that the efficiency of the parser is acceptable and optimized as much as possible if you were to go this route.
  11. That is no longer the case under .NET, Mothra. Variables declared in a list do not default to Object; they are declared as is specified by the As <Type> keywords.
  12. <span id="clock"><script>document.write(getthedate());</script></span>
  13. You'll need to create or open the pipe using the Win32 API, as the .NET class libraries don't provide that functionality. However, once the pipe is created/opened I believe you can use the FileStream class to read and write to it.
  14. Dim dt As DateTime = New DateTime(2003, 6, 26) dt.ToString("MMMM dd yyyy")
  15. If you need to return more than one object to your business tier, than yes, you are headed in the right direction. A method shouldn't be shared if it relies on a particular instance of its class. Take the following two examples for instance: Public Class Math Public Shared Function Add(iFirst As Integer, iSecond As Integer) As Integer Return iFirst + iSecond 'Yes, I realize there could be an overflow exception End Function 'Add End Class 'Math The above method should be shared. It gets all its parameters from its argument, and none from instance members of the class. Now take this code snippet for example: Public Class Math Private iAddend As Integer = 100 Public Property Addend() As Integer Get Return iAddend End Get Set(ByVal value As Integer) iAddend = value End Set End Property 'Addend Public Function Add(iNumber As Integer, iSecond As Integer) As Integer Return iNumber + iAddend 'Yes, I realize there could be an overflow exception End Function 'Add End Class 'Math This Add method relies on a property that was set prior to its invoking. Therefore, it can't be shared.
  16. That's simply incorrect. Here's an exert from the Data Access Layer of Microsoft's own PetShop implementation to validify my statements: /// <summary> /// Read an order from the database /// </summary> /// <param name="orderId"></param> /// <returns></returns> public OrderInfo GetOrder(int orderId) { //Create a parameter SqlParameter parm = new SqlParameter(PARM_ORDER_ID, SqlDbType.Int); parm.Value = orderId; //Execute a query to read the order using (SqlDataReader rdr = SQLHelper.ExecuteReader(SQLHelper.CONN_STRING_DTC_ORDERS, CommandType.Text, SQL_SELECT_ORDER, parm)) { if (rdr.Read()) { //Generate an order header from the first row CreditCardInfo creditCard = new CreditCardInfo(rdr.GetString(2), rdr.GetString(3), rdr.GetString(4)); AddressInfo billingAddress = new AddressInfo(rdr.GetString(5), rdr.GetString(6), rdr.GetString(7), rdr.GetString(8), rdr.GetString(9), rdr.GetString(10), rdr.GetString(11), rdr.GetString(12), null); AddressInfo shippingAddress = new AddressInfo(rdr.GetString(13), rdr.GetString(14), rdr.GetString(15), rdr.GetString(16), rdr.GetString(17), rdr.GetString(18), rdr.GetString(19), rdr.GetString(20), null); OrderInfo order = new OrderInfo(orderId, rdr.GetDateTime(0), rdr.GetString(1), creditCard, billingAddress, shippingAddress, rdr.GetDecimal(21)); ArrayList lineItems = new ArrayList(); LineItemInfo item = null; //Create the lineitems from the first row and subsequent rows do{ item = new LineItemInfo(rdr.GetString(22), string.Empty, rdr.GetInt32(23), rdr.GetInt32(24), rdr.GetDecimal(25)); lineItems.Add(item); }while(rdr.Read()); order.LineItems = (LineItemInfo[])lineItems.ToArray(typeof(LineItemInfo)); return order; } } return null; } Take note of OrderInfo, which is defined as the function's return type. This type is defined in PetShop's business tier (BLL). As for your other questions regarding DataSets I really see no reason for their use at all. A faster and more appropriate solution would be to retrieve the application's data using DataReaders which would in turn place their contents into new instances of your BLL objects, as is displayed above in both my example and Microsoft's PetShop exert.
  17. I can't think of a single reason as to why one would need to do that. Nevertheless... SELECT id FROM table Then loop through the returned records to find the "missing" rows. For each missing row execute the following T-SQL: SET IDENTITY_INSERT dbo.tablename ON GO INSERT (id) VALUES (<identity>) INTO dbo.tablename GO ... replacing "<identity>" with the one just found.
  18. http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/Q253/6/67.asp&NoWebContent=1
  19. You're oversimplifying the function of the data tier far too much. The data tier should be returning business tier objects that can then be used without any knowledge of the underlying database. For instance, you have the following two classes defined in your business tier: Public Class Project '... End Class 'Project Public Class ProjectCollection Inherits ArrayList '... End Class 'ProjectCollection A method call to your data tier's GetProjects member returns a ProjectCollection object that is populated with one or more Project objects. public ProjectCollection GetProjects() { SqlConnection connection = new SqlConnection(); SqlCommand command = new SqlCommand(); SqlDataReader reader; connection.Open(); command.CommandText = "SELECT * FROM dbo.projects"; command.Connection = connection; reader = command.ExecuteReader(); ProjectCollection pc = new ProjectCollection(); while (reader.Read()) { Project p = new Project(); //... pc.Add(p) } reader.Close(); connection.Close(); return pc; } // end method GetProjects You could then go ahead and pass that ProjectCollection object to your presentation tier which would in turn display the current projects in a form or web form.
  20. I'm sick and tired of seeing thread titles such as "please, PLEASE read", "I'm an invalid so help me now!" or simply "help". Titles like these add nothing to the community, and they make searching for answers more difficult than it has to be. Threads with titles such as these should just be deleted. Also, after reading Paul's thread I'd like to bring the same such guideline here for an open discussion. While I'm certain no one would bother to read such a guideline (nor does it matter if they didn't) it would justify any action by a moderator to remove incorrect or misleading content.
  21. They're there. You're just missing them. System - System.Data - - System.Data.OleDb
  22. <%@ Page SmartNavigation="True" %>
  23. You can also use the ExecuteScalar method of the SqlCommand object if the data type is an appropriate fit (boolean, integer, etc.).
  24. It appears to be working as expected. A root drive is not specified in the constructer of the DirectoryInfo object, and therefore the root will default to the current working directory.
  25. Dim sQuery As String = "DELETE FROM [Table1] WHERE [Table1].[iD] = '" & TextBox1.Text.Replace("'", "''") & "'" ... should work just fine assuming that the field "ID" was defined in the table as a string or character value.
×
×
  • Create New...