Jump to content
Xtreme .Net Talk

Joe Mamma

Avatar/Signature
  • Posts

    1093
  • Joined

  • Last visited

Everything posted by Joe Mamma

  1. TimeSpan ts = DateTime.Now - DateTime.MinValue; MessageBox.Show(ts.TotalDays.ToString()); or, even simpler: MessageBox.Show((DateTime.Now - DateTime.MinValue).TotalDays.ToString());
  2. MessageBox.Show(DateTime.Now.ToString("MMMM")) MessageBox.Show(DateTime.Now.ToString("MMM"))
  3. Dim s As String = New System.Text.ASCIIEncoding().GetString(decodedbytes)
  4. look up Math.ATan - complete example
  5. or Dim lineAngle as Double = Math.Atan2(Y2-Y1,X2-X1)
  6. NOTE THAT ATAN IS A DOUBLE!!!!
  7. nope. . . Dim lineAngle as Double = Math.Atan((Y2-Y1) / (X2-X1))
  8. Look into the System.IO namespace
  9. Oh it is sad that simple trigonometry is 'weird' look up Math.Atan
  10. oh yeah. . . Ignite both ends of Rope1, Ignite one end of Rope2. When Rope1 is exhausted (thirty minutes), Ignite other end of Rope2 (now a thirty minute rope) which will exhaust now in 15 minutes.
  11. question. . . You want the user to be able to add activities to your database??? so lets say you had in the activity table: -------------- Walking Running -------------- The you want the the combo box to look something like this when dropped down: [____________]V |_____Walking_| |_____Running_| Now, lets say your user "fat-fingers" the combo box and enters: [_____Valking]V |_____Walking_| |_____Running_| and submits, Do you really want the database to reflect - -------------- Walking Running Valking -------------- ??????
  12. tan θ = (Y2-Y1) / (X2-X1) θ = arctan((Y2-Y1) / (X2-X1))
  13. depending on where in your code you are casting, in c# it is best to use the as operator and then test for null: IComparable test = yourObject as IComparable; if (test != null) test.Compare(...);
  14. look up: DataRowCollection.Find DataView.Find DataTable.Find boom goes the dynamite!!! now, there are exceptions to every rule: If you are working with a custom data object framework as a data access layer, you will iterate through the dataset/datatables and load the data into your custom objects, but your objects should implement IEditableObject while your custom lists should implement IBindingList.
  15. try select MyNtextField from MyTable where MyNtextField like "<Long Text>"
  16. its not your fault. . .vbsux was just awful! and the advice alot of people give is dead wrong! No, databind=good. . . always has been good! just vbsux hid so much from the user and the help files were attrocious. I learned it in Delphi whci comes woith the source code that is Delphi. I highly recommend getting Delphi for the source code alone! hmmm. . .isnt a dataset a collection? a collection of datatables (among other things) and a datatable is, among other things, a collection of rows. BINGO!!!! and. . . heres the kicker. . . in vbsux, it wasn't necessary either, because. . . . Recordsets are collections!!!! Just disconnect the recordset! You look around the xtremevbtalk forum and you see "experts" RECOMMENDING getting a recordset, itterating through the recordset to load an array/collection and then iterating through that to load a grid. HUH???? you got the collection - the recordset. just set the list's datassource to the recordset and "boom goes the dynamite!" the grid is loaded!!!!
  17. select Cast(MyNtextField as Varchar(8000)) MyNtextField from MyTable
  18. are your Numerics really numerics, or can you get away with specifiying them as integers???? updateCommand1.Parameters.Add(New OleDb.OleDbParameter("PID", OleDb.OleDbType.Integer)) updateCommand1.Parameters.Add(New OleDb.OleDbParameter("EventAge", OleDb.OleDbType.Integer)) updateCommand1.Parameters.Add(New OleDb.OleDbParameter("Weight", OleDb.OleDbType.Integer)) updateCommand1.Parameters.Add(New OleDb.OleDbParameter("Height", OleDb.OleDbType.Integer)) updateCommand1.Parameters.Add(New OleDb.OleDbParameter("StudyType", OleDb.OleDbType.VarChar, 40)) updateCommand1.Parameters.Add(New OleDb.OleDbParameter("RNADate", OleDb.OleDbType.Date)) updateCommand1.Parameters.Add(New OleDb.OleDbParameter("StudyNo", OleDb.OleDbType.VarChar, 15)) updateCommand1.Parameters.Add(New OleDb.OleDbParameter("Location", OleDb.OleDbType.VarChar, 30)) updateCommand1.Parameters.Add(New OleDb.OleDbParameter("Indication", OleDb.OleDbType.Integer)) updateCommand1.Prepare() should work. . . else, you will have to specify precision/scale before preparing: updateCommand1.Parameters.Add(New OleDb.OleDbParameter("PID", OleDb.OleDbType.Numeric)) updateCommand1.Parameters.Add(New OleDb.OleDbParameter("EventAge", OleDb.OleDbType.Numeric)) updateCommand1.Parameters.Add(New OleDb.OleDbParameter("Weight", OleDb.OleDbType.Numeric)) updateCommand1.Parameters.Add(New OleDb.OleDbParameter("Height", OleDb.OleDbType.Numeric)) updateCommand1.Parameters.Add(New OleDb.OleDbParameter("StudyType", OleDb.OleDbType.VarChar, 40)) updateCommand1.Parameters.Add(New OleDb.OleDbParameter("RNADate", OleDb.OleDbType.Date)) updateCommand1.Parameters.Add(New OleDb.OleDbParameter("StudyNo", OleDb.OleDbType.VarChar, 15)) updateCommand1.Parameters.Add(New OleDb.OleDbParameter("Location", OleDb.OleDbType.VarChar, 30)) updateCommand1.Parameters.Add(New OleDb.OleDbParameter("Indication", OleDb.OleDbType.Numeric)) // Specify Precision and size for numerics: updateCommand1.Parameters["PID"].Precision = {some precision}; updateCommand1.Parameters["PID"].Scale = {some scale}; updateCommand1.Parameters["EventAge"].Precision = {some precision}; updateCommand1.Parameters["EventAge"].Scale = {some scale}; updateCommand1.Parameters["Weight"].Precision = {some precision}; updateCommand1.Parameters["Weight"].Scale = {some scale}; updateCommand1.Parameters["Height"].Precision = {some precision}; updateCommand1.Parameters["Height"].Scale = {some scale}; updateCommand1.Parameters["Indication"].Precision = {some precision}; updateCommand1.Parameters["Indication"].Scale = {some scale}; // now prepare updateCommand1.Prepare()
  19. THEORETICALLY. . . a primary key is the LOGICAL group of fields that together specify a unique LOGICAL entity that a table represents. Remember a row in a table is a relation, that is, the data is related. Often times, people erroneously use a numeric ID to be the primary key. . . The MS northwind Categories table is an example. If I were desinging Northwind, I would make CategoryName the primary key, because CategoryName uniquely specifies a Category entity. I would then add the CategoryID as an autonumber and uniquely index that (called a surrogate key.) There are many times that it is a combination of fields that specifies a unique entity - for example, imagine USCity and USState: underline represents the primary key Logically, usstate could be something like usstate(name, abbrev, population, area) and uscity could be something like uscity(usstateAbbrev, name, population, area) in usstate, I would make 'abbrev' not null uniquelly indexed (a surrogate key) and the physical structure would be identical. . . Physcally, in uscity, I would add an autonumber ID field and make it not null uniquely indexed (another surrogate key) : city(usstateAbbrev, name, population, area, ID) Then, when making a child table relation, I would populate child tables with the surrogate key of uscity instead of bringing both primary key values to the child table . . . for example, a person: usperson(SSN, firstname, lastname, birthcityID) where birthcityID is the uscity they were born in. again, the key idea here is that primary key is the LOGICAL combination of fields that specifies a unique entity represented by a table relation. Logically, a State and Name, uniquely specify a US city. Normalization and "Surrogate Key" By the way. . . you can get a doctorate in this stuff. :)
  20. As long as the DataAdapter is not destroyed after initial creation, no, the internal OleDBCommand objects are still available to you. You can check to see if the SelectCommand object is null, or if not null, the command text is still there. Man. . . VBSux did so many people a disservice. Ther above is is an example of old vb coders being confounded by databinding. [indent]Dim conn As New OleDb.OleDbConnection("Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Northwind;Data Source=localhost") Try [indent]Dim da As New OleDb.OleDbDataAdapter("select * from Categories", conn) Try [indent]Dim ds As New Data.DataSet da.Fill(ds) ListBox1.DataSource = ds.Tables(0) ListBox1.DisplayMember = "CategoryName" ListBox1.ValueMember = "CategoryID" [/indent] Finally [indent]da.Dispose() [/indent] End Try [/indent]Finally [indent]conn.Dispose() [/indent] End Try [/indent] If in vbsux or vbnot you are iterating through a recordset to load grids/lists/collections, etc. . . YOU ARE DOING IT WRONG!!!!!!!
  21. yepper! it does!
  22. the vb formatting screwd up. it should have read: isn't dim i as picturebox = new picturebox the equivalent of [indent]dim i as picturebox i = new picturebox [/indent] I don't think you can do dim i as new picturebox in vb.not, can you?
  23. works as expected for me.
  24. I have never had this problem before, unless, there was an existing .ldf file in the old file path of the .mdf. If I use enterprise manager, and no exisiting ldf file is found, I get a warning but a new ldf is created
×
×
  • Create New...