Jump to content
Xtreme .Net Talk

haroldjclements

Avatar/Signature
  • Posts

    47
  • Joined

  • Last visited

Everything posted by haroldjclements

  1. Hello all, I wander if anyone can help me. I am trying INSERT some data at a specific place in my database, but I can�t seem to get it right. My SQL statement is: String sql = "UPDATE Players SET OldAppPosition = 10 WHERE PlayerID = 99"; I am using J# .NET with an Access database using OleDbConnection. My problem is that I don�t know how to execute the query. I have the connection setup, I just can�t workout how to do it. Any help will be gratefully received. Thanks, Harold Clements
  2. Thanks Winston, I feel a little stupid as I know the �elementAt� and have used it in my Java applications numerous times just did not associate it with the �get� method. It takes me back to the early days of learning Java when the tutor said to me �There is sometimes more then one method in the class that does, more of less, the same thing. That�s why they keep deprecating methods in each new version�. Well am happy now, I have been stuck on this for a while now. Cheers again, Harold Clements
  3. What I was really trying to get at was that the above code (using an iterator with a vector) works fine if you were programming with the Java JDK1.4.2. However in J# some methods (which are available in Java) are not in J#. For example there is also a 'get' method in the JDK version of Vector with in non-existent in J#, which makes it very hard to migrate.
  4. I have a problem with the Iterator in J#. In standard Java this code would have run through all the elements in �myVector� and would have worked fine. I have imported both java.util.Vector and java.util.Iterator. Iterator myIterator = myVector.iterator(); while (myIterator.hasNext()) { AnObject myObject = (AnObject) myIterator.next(); } In J# I receive this error and I don�t know how to fix it Cannot find method 'iterator()' in 'java.util.Vector' If anyone has any clues I would be very grateful. Thanks in advance, Harold Clements
  5. ok, I have worked it out. Using the try and catch you can tell your program to just ignore that error. Hope this helps someone. Harold
  6. Hello All, I have set up a contract start date and a contract end date. I whist to send the method a date and for it to return true if the date is between the contract start and end dates. My problem is that I don't know how to do this! Any help will be greatfully received, Harold Clements I am using j#.
  7. I have a problem with reading null value from my database. The connection works and does retrieve the data. However if there is an empty cell in the database it creates an exception �java.lang.classCastException: Specified cast is not valid� while (myDataReader.Read()) { description = myDataReader.GetString(0); //The error is here! custPN = System.Convert.ToString(myDataReader.GetString(2)); //custPN = myDataReader.GetString(2); sql = "SELECT Name FROM tblSupplier WHERE SupplierID = " + myDataReader.GetInt16(1); } I have tried to convert the output to a string, but that did not work. I think that the problem is with the .GetString() line as a blank cell is not a string. This cell is not always empty so .GetString() works fine when it's not. If anyone could help me I will be eternally grateful
  8. How would I use the ToString() method on the following line (in J#). The line that is causing the problem is: custPN = myDataReader.GetString(2); Basically my problem is as above.
  9. Thanks for your input VBAHole22, its very much appreciated.
  10. Hello All, I am just wandering if anyone has a better way of implementing the following: I am drawing search results (description of an item) from a database and populating them in a listbox. I need to map the element numbers, that are automatically allocated to the items when added to the lsitbox, to the description’s unique ID. I can’t use an array because I don’t know the length of the search results. The only way to do this is to do a ‘count’ in the SQL statement then go back and populate the listbox and array. However this idea will be time consuming. Another idea I have was to use a Vector (as they grow and shrink to your needs). The problem with this is that a Vector collection does not collect raw data types, which means each search result will be an object, which will use lots of memory. The last way I thought of was to limit the search results to 50, that way I will be able to create an array of size 50 and just display a message requesting the user to narrow down the search criteria. I was wandering if anyone had any better ideas for mapping the elements? Thanks for your time, Harold Clements
  11. Thanks for your comprehensive response, it is very much appreciated. I will give it a try. Thanks again, Harold Clements
  12. Thanks "mutant" much appreciated
  13. By all my post recently you can probably tell that I am new to the J# language. So I apologise for the silly questions. However I have another one. I want to clear a listbox. Now I know its something like ListBox1.Items.Clear() but that is not it in the j# syntax. If anyone can help me I will be much appreciated. Thanks, Harold Clements
  14. Hello All, I have created an application that reads items from a database. What I want to do now is create an array of text boxes that are populated with the data retrieved from the database. The problem is that I am unsure how to create an array of textboxes at runtime. I can use the .set_Size() method to place the box. So far I have: System.Windows.Forms.TextBox [] tbxResults = new TextBox[20]; while (myDataReader.Read()) { tbxResults[loopControl] = new TextBox(); tbxResults[loopControl].set_Location(new System.Drawing.Point(8, y)); tbxResults[loopControl].set_Visible(true); loopControl ++; y += 24; } However the does not work. Any help will be most appreciated Harold Clements
  15. Hello All, I have created an application that pulls data from a database using an OleDbDataReader. It used a wile loop to collect the data from each line. Now this works fine until it comes across an empty cell in the database. I have caught the exception “No value for one or more required parameters”. How do I get the OleDbDataReader to read an empty cell? Thanks for your help, Harold Clements
  16. Got it! It's me being a prat! System.Environment.get_NewLine(); Forgot the () on the end. Cheers for your help eveyone. Harold.
  17. Still Can't Get It! Cheers for your reply guys The ‘\\n’ doses not work. The 'Environment.NewLine' is not in J#, in its places (I think) is 'System.Environment.getNewLine’. However I get the compilation error “Cannot resolve name’ Any ideas what I am doing wrong? Thanks for you help, Harold
  18. Hello All, Just a quick question. I have written a little app that lists the users in a database and the results are displayed in a ‘label’ on a form. My problem is that I can not create a line break, therefore I get results like this: Harold Clements Dave Brown Iain Smith Lee Cooper Where I want: Harold Clements Dave Brown Iain Smith Lee Cooper In traditional Java you have the ‘\n’ but in J# that creates a compiling error. Any suggestions will be gratefully received, Harold Clements
  19. Yep, your right ..... sorry! Cheers mate :D
  20. I have tried that and I get the error: "Cannot find field 'get_Items' in class 'System.Windows.Forms.ComboBox' I have "import 'System.Windows.Forms.*;" in my code.
  21. I have a problem with converting my VB.NET code to J#.NET Dim x For x = 1 To 31 Me.cbxDays.Item.Add(x) Next I know the loop in J#, just not the code for adding the item to the combo box! for (int x=1; x<32; x++) { this.cbxDays.??????????(x); } Any help will be appreciated. Thanks, Harold Clements
×
×
  • Create New...