Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
K

Kyle Wood

@Kyle Wood
About
Posts
5
Topics
2
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Updating an Access database based on a sub-select
    K Kyle Wood

    More on this.. I've just stripped out all but this years dates and run my query which has done exactly as I expected and updated 25 & 28/12. I guess its just baulking at the number of repetitions it has to perform on the full table so I'm on the right track but do need to improve the code.

    Database database question announcement

  • Updating an Access database based on a sub-select
    K Kyle Wood

    Thanks for the reply Mycroft but I'm not sure that it is of much help. Take this year for example. 25/12 is a Friday, 26/12 is a Saturday so 28/12 is actually a holiday not a working day. My inner select statement returns 2 rows correctly containing Friday 25/12 and Monday 28/12. I then have to check every row in the table against these returned values and if equal mark the date as a non-working day (my outer update). The inner select works a treat so I thought an update statement where date in (inner select) would achieve what I wanted but for some reason it appears to do nothing, no rows returned updated and no exception thrown. Maybe its looping too many times and would eventually finish. I'll have to re-visit my code and see if there's a better way.

    Database database question announcement

  • Updating an Access database based on a sub-select
    K Kyle Wood

    I have an Access database which contains every date between 01/01/2009 and 21/12/2029. In a 2nd column is a char value indicating whether the date is a working day or not. I need to decide whether xmas & boxing day fall on a non-working day and if so adjust the working day column value. I have the following to calculate the adjusted dates:

    SELECT switch((DATEPART("w",FullDate,2) In (6,7)),DATEADD("d",+2,FullDate),(DATEPART("w",FullDate,2) Not In (6,7)),FullDate)
    FROM UKWorkingDays
    WHERE DATEPART("m",FullDate,2)=12 And DATEPART("d",FullDate,2) In (25,26);

    If I wrap this in an update statement the SQL appears to execute but does nothing at all

    UPDATE UKWorkingDays SET WorkingDay = "B"
    WHERE FullDate in
    (

    SELECT switch((DATEPART("w",FullDate,2) In (6,7)),DATEADD("d",+2,FullDate),(DATEPART("w",FullDate,2) Not In (6,7)),FullDate)
    FROM UKWorkingDays
    WHERE DATEPART("m",FullDate,2)=12 And DATEPART("d",FullDate,2) In (25,26)

    );

    Can anyone give me any assistance please ?

    Database database question announcement

  • Using foreach to run thru an arraylist containing a struct
    K Kyle Wood

    Thanks J4amieC. If I'd noticed what the tags were telling me when I hovered over the foreach I'd have seen this for myself. I removed the declaration of the DBList in form 2 and qualified the DBList in the foreach with the form 1 instance and it all works !! A case of not spotting the obvious. :)

    C# database help question

  • Using foreach to run thru an arraylist containing a struct
    K Kyle Wood

    I have the following code extract: public arraylist myList = new arraylist(); public struct myDBList { public string strKey; public string strName; public string strDataSetName; } I loop thru a list of databases and add data from each to my list: foreach (database db in dbList) { myDBList.strKey = db.Key.ToString(); myDBList.strActual = db.Name.ToFriendlyString(); myDBList.strDataSetName = db.Path.ToFriendlyString(); myList.Add(myDBList); } this arraylist is then passed to a 2nd form with: Form myLogon = new Form(); myLogon.passedList = myList; In the 2nd form I have declared the same arraylist & struct and I want to loop thru the list and extract the data so I use: ArrayList newList = new ArrayList(); public struct myDBList { public string strKey; public string strName; public string strDataSetName; } string key; public arraylist passedList { get{ newList = value; } } and in the code: foreach( dbList db in newList) { key = db.strKey; . . } While the code compiles, when I come to execute the foreach statement i get the error: InvalidCastException was unhandled - specified cast is not valid What am I doing wrong here ??

    C# database help question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups