Jump to content
Xtreme .Net Talk

Afraits

Avatar/Signature
  • Posts

    73
  • Joined

  • Last visited

Everything posted by Afraits

  1. Hmm, DateTime.subtract has 2 overloaded methods, when you pass a datetime var in it returns a timespan - while if you pass in a timespan it returns a datetime. So not as simple as I thought (mental note read the whole helpfile :D). Unless they've changed this for framework V2 I think you'll have to write your own Datediff or use the VB6 namespace. Need to think about this one a bit more.
  2. Use the DateTime subtract method eg DateDiffVar=mydatevar.Subtract(EarlierDateVar) This will subtract EarlierDateVar from mydatevar and leave the difference in DateDiffVar. You can then use the .ToString(format) or .Month .Day or .Year methods to give you the values you are after.
  3. It can also mean a typo when entering a SQL statement eg Select * From [Mytable] where [Mytalbe].[GroupID]=10 because the Mytable is spelt incorrectly in the where clause the parser sometimes assumes that it is expecting a paramter, though my experience with this particular exception has been when using MS Access Dbs
  4. I've got a feeling that Vb treats anything other than a 0 as true (though i might be thinking of something else) which means there would be no problem. Logic wise if you want to test for true use something along lines of Not(Value =false) As false is the same in both cases and and will return true for either 1 or -1.
  5. Not that I'm aware of. I had to use a similar method for a similar problem a few months back.
  6. Further to IsDate the use of regular expressions would allow you to check that a string matches a valid Date format and save you from having to catch the exception thrown by using DateTime.Parse on an invalidly formatted string.
  7. From MSDN The suggested method is to use DateTime.Parse or DateTime.ParseExact and catch the exception thrown which I don't find particularly satisfying. However if this is to check user input then investigate the DateTimePicker control (instead of textboxes for example) which will always return valid dates for you as DateTime objects without the need to check the format.
  8. And for InStrRev Dim s as String = "asdfa" Dim x as Integer = s.LastIndexOf("a") Gives x=4
  9. No problem, its one of those things I banged my head against the wall over a year or two back, trust me, you won't forget this solution :)
  10. Maybe fully qualify all the fields so it looks like Update [NumberGen] set [NumberGen].[Counter] = ~ where ([NumberGen].[iD] like 'SK') I can see nothing wrong with the syntax you have so this is the only thing I can think of. I presume you've checked what strSQL contains after the replace, though posting that might help shed some light on it.
  11. I'd hoped the smilies had given the impression that I didn't really mind and that the comments were taken on board with good humour, and also that I knew no-one wanted to gang up me (though it did feel that way on first reading that morning :), though probably more due to atmosphere at work than that here! ). Just shows how easy it is to not make yourself clear... Thanks for the reassurance though.
  12. Try putting [] around the ID to make your SQL as follows: Update NumberGen set Counter = ~ where [iD] like 'SK' Previously I've encountered problems such as this, the Access SQl parser seems to correctly handle it but when running from VB or .NET code I needed to put [] around certain field names to prevent them being interpretted as keywords. Date, Time, Key are other common causes of this.
  13. I assume the Me in this case is relating to datarow or similar object. To my understanding it seems to be doing the following: Me.GetChildRows(Me.Table.ChildRelations("contract_line_item_pricing")) the GetChildRows returns an array of datarows based on the specified relation, the Me.Table.ChildRelations selects the relation between the table the datarow (Me) is from, and the table linked by the relationship. The relationship "contract_line_item_pricing" may be defined in your source data (XML/DB ?) or built when loading into a dataset. The Ctype call will then attempt to convert this array into an array of Pricing objects. Beyond that I couldn't say what it is meant to do or why that might be the case.
  14. Good point, well made. I stand chastised :D . So maybe next time I'll ask why someone wants to do something rather than trying to answer the question and save myself being called a fool 4 times :P Perhaps JDYOder could you tell us why you wanted a resume & resume next syntax so we could try to find you a way to avoid it in the first place? By the way - once is usually enough for me, especially when its a comprehensive an explaination as that provided. :)
  15. Wile's method gives you the resume next equivalent, to do a resume the best I can come up with is this bool retryvar=false; do { try { //do stuff //end loop retryvar=false; } catch(SpecificException Ex) { //known correctable error so correct then retryvar=true;//set var to retry } catch(Exception Ex) { //errorcorrectable fake var to show whether you could retry or not if (errorcorrectable) retryvar=true;//set var to retry else retryvar=false; } }while(retryvar); You could use int var instead of boolean to show return codes and control program flow for subsequent statements. And yes this is very longwinded syntax.
  16. Which update do you get the concurrancy violation on?
  17. Thats because they are VB specific use syntax like: dblvar=(double) expression; intvar=(int) expression;
  18. If you mean that the row has a primary key field, autonumbering ID field or similar then the current version of drRow will provide access to the populated field.
  19. No probs, just for reference if you end up using C# then (type) eg (Int) or (DataView) is the equivalent of the Ctype in VB.NET
  20. For the basic data types yes CInt, etc do the casting or you could look at CType(var, type) for explicit casting of classes into interfaces and the like
  21. As far as I am aware its the only way to handle errors, though you can specify your own error messages to provide more or less information before returning out of the stored procedure.
  22. It will be connected with the foreign key. I would say MySQL is expecting the DiscountPK in tblSalesItems to match a valid entry in tblDiscounts which it can't do because of the null value. I'm not sure about MySQL but for SQL Server, which I normally use, having nulls in foreign key fields is not a good idea. Its depends somewhat on how the constraint has been defined but I expect by having entries in tblDiscounts which correspond to no discount offered will allow you to add the rows into tblSalesItems
  23. Could you explain why you have the tbldiscount in the first place? I'm not sure why you need it. To solve the problem I would avoid the null when no discount is applied and have a 0% discount entry in tbldiscount and populate tblsalesitems with the DiscountPK which matches the 0% entry in tbldiscount.
  24. What about the cunning person who puts the clock forward to say 2010 before installing the app and then once installed returns the clock to its normal setting?
  25. To my mind the same principles apply - technically anything could be a valid text parameter,value to be inserted/updated or searched on and so a parameterised INSERT (or DELETE or UPDATE) applies the same as a SELECT query.
×
×
  • Create New...