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
  1. Home
  2. Web Development
  3. ASP.NET
  4. Connecting to the db automatically according to the current month

Connecting to the db automatically according to the current month

Scheduled Pinned Locked Moved ASP.NET
csharpdatabasehelptutorial
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kandalu
    wrote on last edited by
    #1

    Hi, I am using .net 2.0 & Sqlserver 2005. I have databases for the months, i.e., I have to insert recrods into the db of the current month. For example I can insert and handle records from October db only when the current month is October. But this should happen automatically. Users don't have permissions to change the db. I don't have idea to implement this. Please help me to implement this. Thanks.

    H 1 Reply Last reply
    0
    • K kandalu

      Hi, I am using .net 2.0 & Sqlserver 2005. I have databases for the months, i.e., I have to insert recrods into the db of the current month. For example I can insert and handle records from October db only when the current month is October. But this should happen automatically. Users don't have permissions to change the db. I don't have idea to implement this. Please help me to implement this. Thanks.

      H Offline
      H Offline
      HemJoshi
      wrote on last edited by
      #2

      Hi Kandalu, All the element in the connection string will be same you only have to replace the database name for each month. So just get the curreent month and update the connection string dynamicaly so that the recrods can be insrerted for the current month. Thanx

      K 1 Reply Last reply
      0
      • H HemJoshi

        Hi Kandalu, All the element in the connection string will be same you only have to replace the database name for each month. So just get the curreent month and update the connection string dynamicaly so that the recrods can be insrerted for the current month. Thanx

        K Offline
        K Offline
        kandalu
        wrote on last edited by
        #3

        Hi HemJoshi, Thanks for your quick reply. I thought like you. But I don't know where to set the connection string either as an application variable or at the page load event? In .net if we change the current date, the changed date only appear when we use the "DateTime.Now()" function. I don't know how to get the correct date whenever the user change the date. Could you tell me how to implement this? Thanks.

        H 1 Reply Last reply
        0
        • K kandalu

          Hi HemJoshi, Thanks for your quick reply. I thought like you. But I don't know where to set the connection string either as an application variable or at the page load event? In .net if we change the current date, the changed date only appear when we use the "DateTime.Now()" function. I don't know how to get the correct date whenever the user change the date. Could you tell me how to implement this? Thanks.

          H Offline
          H Offline
          HemJoshi
          wrote on last edited by
          #4

          Hi kandalu, do not use DateTime.Now()it will fatch the client current date.Create a procedure at database side which will return the current date(using getdate()).This will always return the cureent date of the database server. Thanks

          K 1 Reply Last reply
          0
          • H HemJoshi

            Hi kandalu, do not use DateTime.Now()it will fatch the client current date.Create a procedure at database side which will return the current date(using getdate()).This will always return the cureent date of the database server. Thanks

            K Offline
            K Offline
            kandalu
            wrote on last edited by
            #5

            Hi HemJoshi, Thanks. I tried through sqlserver and got it right. Thanks.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

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