Jump to content
Xtreme .Net Talk

Nerseus

*Experts*
  • Posts

    2607
  • Joined

  • Last visited

Everything posted by Nerseus

  1. The most common use for the RecordsAffected property is to check whether the action actually took place. For instance, someone else is deleting a record that you're deleting and they got in first. Your delete may not do anything if the ID passed in isn't found. You might have other code that does an INSERT after a DELETE, but you wouldn't want to insert if the DELETE failed (such as on a Bank Transfer type of transaction). Just adding info... -Nerseus
  2. Where did you put the square brackets? Did you put them on the SQL string, around the columns names "name" and "type" (in your SELECT list)? I would guess at least one of them is a reserved word. -Nerseus
  3. I assume this is SQL server? You'll have to add "SELECT @@IDENTITY" to your SqlCommand and run an actual query, not ExecuteNonQuery. You can use a DataReader or a DataSet - but you need to get the value out. The "SELECT @@IDENTITY" will give you the ID of the last inserted row, in column1 or row1 of your executed statement. You may have to also run "SET NOCOUNT ON" as the first part of your SQL statement as the rowcount of the actual INSERT may cause problems with retrieving the ID (I can't remember). Here's the final SQL statement that should be built (all in one SQL string): SET NOCOUNT ON Insert employees (lastname,firstname,department) Values (@thelastname,@thefirstname,@thedepartment) SELECT @@IDENTITY -Ner
  4. I don't think the XML format matters, as long as you know what it is and your Tree-building code knows about it. I'm not really sure what other options you have other than attribute-based XML, which would probably be harder to code an XML-To-TreeView piece of code for. I didn't really look in detail at your code, as far as whether it will work or not. It sounded like it was working so I didn't see the need. Keep in mind that XML is only what you want it to be. If you just need a structure that helps you build a tree, then what you have is perfect. If you happen to need more detail, then it's up to you to add it to the XML. What kind of XML sites were you looking for? There are XML standards (for certain types of data), there's XSLT, XML parsing, and 5 million other topics. :) -Ner
  5. Depending on what you're trying to accomplish, there could be an easier solution. Maybe each button has some data associated to it. You could put the data in the Tag property of each button and using the sender parameter, pull out the data of whatever button was clicked. If you tell us more about what you're trying to do, specifically, with each button's click event, we can help more. -Ner
  6. I'd have to see some of your code to know how you're saving things from Form1. Only then can I suggest something for Forms 2 and 3. -Nerseus
  7. It's a little large, but that's not bad by itself. You can break out some of the code to a separate function if readability becomes an issue. However, this part is bad: If Not POTotal() Then Return End If ' close connection to database m_objConn.Close() If you return when POTotal returns False, you won't close the connection. -Nerseus
  8. You won't be able to use picturebox's for that type of game. The transparency doesn't layer on top of other picturebox controls. You can use GDI+ to do all the drawing through DrawImage calls (on a Graphics object), or you can use something like DirectX9 (which includes DirectDraw for 2D drawing). -Nerseus
  9. Nerseus

    Speed up

    You can check out DirectX4VB for a tutorial and sample. I'm not familiar with the AnimatePaletter project so I can't say what it's doing. Do all of the sample projects have this "stuttering" effect? Have you tried changing to Release mode and running outside the IDE? -Nerseus
  10. Try this: ' <snipped from your code sample> OleDbDataAdapter1.Fill(DsJobNames1, "Jobs") Dim ArrayJobNames As ArrayList = New ArrayList() Dim row As DataRow For Each row In DsJobNames1.Tables("Jobs").Rows ArrayJobNames.Add(New LookupItem(row("JobId"), row("JobName").ToString())) Next 'Populate Combo Box cmboJobNames.DataSource = ArrayJobNames cmboJobNames.DisplayMember = "Text" cmboJobNames.ValueMember = "ID" The DisplayMember and ValueMember need to be the names of the properties of the object that's being bound to. Since you're binding to an ArrayList of LookupItem objects, the combo will see the properties of the LookupItem, not of the DataTable. That's why Displaymember and ValueMember are Text and ID and not JobId and JobName. The JobId and JobName strings are only used to get the right columns from the DataTable into a LookupItem object. Have fun! -Ner
  11. You'll need to create another class and add the class object to your combo instead. I've attached a sample that shows what I mean. There's a class I created called LookupItem (in LookupItem.vb). I add a couple of instances to an ArrayList and bind the combo to the ArrayList. -Nerseus windowsapplication2.zip
  12. Try this sample project. -Ner windowsapplication1.zip
  13. It looks mucho prettier now, thanks! I tried to say something earlier on the chat window itself, but no one was listening or they were afk. Thanks for adding the chat, btw. -Nerseus
  14. And you can change it at any time through the "user cp" link at the top of the forums. Click on the "Edit Options" link to change your cookie usage. -Nerseus
  15. Nerseus

    Speed up

    Still, one rectangle at size 259x347 should NOT be slow on pretty much any machine. I see you're using DirectDraw, which is made for blt'ing images of various size - ignore my earlier comment about bitmaps with power of 2, that's more for Direct3D. If your sample is still running slow when you go back to the 259x347 image, post up the project and we can take a look. -Nerseus
  16. I assume Class1 is an object created in the form. The form is callign the Action1 method on the instance of Class1. The form certainly knows about the ComboBox and can pass it along to the class. -Ner
  17. Did she mention where/how you have to find it? If you return ALL rows, you can use the Rows.Count property of the DataTable to get to the last row. Make sure you sort first: // Assume you added "ORDER BY ID" to your SELECT statement (ascending) DataRow row = ds.Tables["Table1"].Rows[ds.Tables["Table1"].Rows.Count-1]; // Grab the value: decimal endingBalance = (decimal)row["EndingBalance"]; You can also use: // Does NOT assume you added "ORDER BY" to your SELECT statement // Sort by column "ID" descending DataRow[] rows = ds.Tables["Table1"].Select(string.Empty, "ID desc"); // Grab the first row - sorted descending works nice DataRow row = rows[0]; // Grab the value: decimal endingBalance = (decimal)row["EndingBalance"]; Or, you can write the SQL to just grab the last row: "SELECT TOP 1 EndingBalance FROM Transactions WHERE Username='" & strUsername & "' ORDER BY ID desc" The ORDER BY will sort in descending order. The "TOP 1" returns only one row. Together, they'll give you the last record in the table. -Ner
  18. If you use an ArrayList object instead of a standard array, you can use the Sort method. -Nerseus
  19. .NET only comes with a standard TextBox and a Checkbox to go in the grid. Anything else will have to be coded yourself (or taken from other sample code) or bought (through a 3rd party vendor). I'd google for "DataGridColumnStyle combobox" if you want to code this yourself. The first hit returned this. -Nerseus
  20. Didn't you see jjjamie's post? Here's the code: ' Put this in Class1 Public Sub Action1(ByVal ComboBox As ComboBox, ByVal Item As String) ComboBox.Items.Add(Item) End Sub You can leave off Item if you want, if the Class1 object is going to know what to add. -Nerseus
  21. Use the [ vb ] and [/ vb ] tags (minus the spaces). You can also use [ code ] for generic code and [ cs ] for C#. -Nerseus
  22. I think he's 7. His brother is only 5 and almost there. He gave up on the old MCSD track to go for the new .NET version, but it's slowed him down. -Nerseus
  23. Nerseus

    Speed up

    Well sure..... but maybe you should try fixing the problem first :p -Ner
  24. Here's something that you should check out: Weaning Developers from the CommandBuilder. It's an article provided by Microsoft. -Nerseus
  25. It looks pretty good except for lack of comments. For something this complex, it would be nice to break apart some of the code to more easily see what's going on. For example: Dim TotalWeeks As Integer Dim NumWeeks As Double ' Find the number of weeks for this contract TotalWeeks = DateDiff(DateInterval.WeekOfYear, m_Commencement, m_Expiry, FirstDayOfWeek.Sunday) ' Get the number of weeks for this contract NumWeeks = CDbl(WeekDiff / m_Frequency) ' Round down the number of weeks so that the last ' week is guaranteed to be within the bounds of the contract intNumberOfWeeks = Math.Floor(NumWeeks) -Nerseus
×
×
  • Create New...