Jump to content
Xtreme .Net Talk

Derek Stone

*Gurus*
  • Posts

    1910
  • Joined

  • Last visited

Everything posted by Derek Stone

  1. You need to import System.Data.SqlClient.
  2. Dim oConnection As New SqlConnection() Dim oCommand As New SqlCommand() oConnection.ConnectionString = "<INSERT YOUR CONNECTION STRING HERE>" oConnection.Open() oCommand.Connection = oConnection oCommand.CommandText = "<INSERT YOUR SQL STATEMENT HERE>" Dim oDataReader As SqlDataReader = oCommand.ExecuteReader() Dim i As Int32 While oDataReader.Read() i = oDataReader.GetInt32(oDataReader.GetOrdinal("<INSERT FIELD NAME HERE>")) End While oDataReader.Close() oConnection.Close()
  3. It might or might not. The application can simply choose to ignore the message, or if you're dealing with an open document the application could display a message box requiring user response. But yes, in most cases the window will be closed, terminating the message pump and ending the application.
  4. If you're familiar with C, you might as well use C#, which is will offer you the same development time as VB.NET, since both are built on the same framework. Regardless, I highly recommend either language for the job, since the built-in Sockets class will provide you with your connectivity. Visual Studio .NET will also offer you quick and easy interface design, through it's Windows Form designers. None are needed for something like this. The framework encapsulates them for you. Don't buy the Standard edition unless budget constraints force you too. It is far too limited for most, in part because it doesn't allow for the creation of class libraries and controls. There is a way to get around that, but simply avoid the problem in the first place and purchase VS.NET Professional.
  5. Associate a DataView object with your data set. DataView objects allow you to rearrange rows, thereby also sorting them. myDataView.Sort = "LastName, FirstName DESC"
  6. For Microsoft Access databases you can simply distribute the .mdb file, and make sure the user has a compatible version of MDAC installed. You'd then use the System.Data.OleDb namespace to interact with one. Things aren't quite the same with SQL Server though. You can't just distribute a file. The user needs to have SQL Server installed, at the very least have access to a server running it.
  7. Let me offer you this example: Public Declare Ansi Function GetWindowText Lib "User32.dll" Alias "GetWindowTextA" ( _ ByVal hwnd As Integer, _ ByVal lpString As StringBuilder, _ ByVal nMaxCount As Integer) As Integer Dim s As New StringBuilder(256) Win32API.GetWindowText(hwnd, s, s.Capacity) MessageBox.Show(s.ToString(), Application.ProductName) Also, for a brief overview of using buffers, take a look at this article: http://www.elitevb.com/content/01,0075,01/05.aspx
  8. Hiding a window does NOT close an application. All it does is remove the window's WS_VISIBLE style. You'd still be left with instances of Word running, which is needless to say, poor programming.
  9. Try to keep them to a minimum. Most errors can be caught in code, and don't really need exception handling at all. I've been known to go error handling crazy myself, so I know where you're coming from.
  10. First things first. Have you called Application.Quit()?
  11. So pogram it that way. There's nothing stopping you from taking the same code that sorts the data when a header is clicked and using it when that property is set.
  12. Compared to what?
  13. You have to click the Microsoft.VisualBasic node in MSDN and then look for the link to the VB.NET reference.
  14. While I agree with you on the Microsoft.VisualBasic issue for the most part, it needs to be said that some of the functions located there are fine to use. That's not to say that many of them are fine to use however. Functions such as FileOpen, Val and StrReverse should just be shot though. Also, while you can remove the Imports Microsoft.VisualBasic statement, that assembly will still need to be referenced nomatter what. The compiler will re-reference it for you if you remove it. Option Strict: Absolutely. Turn it on, no excuses. Imports MS.VB: Use with partial prejudice.
  15. Well, they are in Microsoft.VisualBasic, but you're confusing Microsoft.VisualBasic with Microsoft.VisualBasic.Compatibility. The former is fine to use, as it is part of the framework and contains the VB.NET runtimes. The latter is an absolute no-no.
  16. To be perfectly honest I've never used drag and drop across two different languages, so I'm not sure if it'll even work, especially due to the different nature of .NET. Are you passing the data using a text/string format and are you receiving the data using the same format?
  17. Example The example below should get you going. windowsapplication2.zip
  18. Why is the minimum search length 4 characters and how do I search for less? Searching requires indexing all words from the minimum length on up. To reduce the minimum length from 4 to 3 would require significant resources and slow the whole forum down. A method that can sometimes work when searching for 3 character terms is to use the wildcard * as the fourth character (ex. ADO*, API*). Why does it say <insert name of free email provider here> is a banned email address? This is to help prevent people from mass-registering or registering with fake email addresses. While we don't ban all free email services, when we have repeated problems with users using a service, we add it to the list. In addition, the server was being overwhelmed with bounced mail, mostly from these free email services. Why can't I select an avatar (have an image under my username in posts)? You need to accumulate 25 posts before you can have an avatar. This helps us to lessen server load and keep users who only visit a few times from taking up valuable server space with their uploaded images. Thanks Keith for getting these together.
  19. Dim iInteger As Integer Try 'Cause a divide by zero error iInteger = 7 / 0 Catch e As DivideByZeroException 'Catch the error Catch ex As Exception 'Catch other errors End Try
  20. Well, that's what you get for ignoring the huge warning that tells you not to modify the designer generated code. Have fun recreating the form. Let this be a lesson learned.
  21. You don't simulate the clicking of the header. Instead you create a property that remembers for you. This property is then updated when the user clicks a header, or when your program changes the sorting.
  22. Associate a DataView object with your connection. The DataView class allows you filter which rows are displayed.
  23. If Not IsDBNull(objDataSet.Tables("Shipping").Rows(i - 1).Item("SHIP_TO") Then strCurrent = objDataSet.Tables("Shipping").Rows(i - 1).Item("SHIP_TO") End If
  24. Dim imgMain As Image = Image.FromFile("C:\mybitmap.bmp") You shouldn't be loading more Image objects after this. Use the DrawImage method I posted above to draw the individual sprites where they need to go. DrawImage allows you to specify which part of a larger image you want to paint.
  25. The background color only updates after the control receives a paint message, meaning that at design time only the BackColor of the TextBox itself is updated, not the rounded edges, when the BackColor property is changed. Otherwise it works pretty good. Glad to see you ported it over.
×
×
  • Create New...