Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    New Coder
    Join Date
    Jun 2012
    Posts
    44
    Thanks
    17
    Thanked 0 Times in 0 Posts

    Question How to prevent hard code?

    Hi guys,

    I am using Microsoft Access as my database and currently I am facing a problem, how can I prevent from hard code?

    Such as
    Code:
    WHERE ID = 1
    . Can I use something to replace 1 to make it more dynamic? Which mean once I update from my database table, then the data will automatic up to date for me without opening up my code to change
    Code:
    WHERE ID = 1
    to
    Code:
    WHERE ID = 2
    maybe?

    Thanks in advance.

  • #2
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,633
    Thanks
    4
    Thanked 148 Times in 139 Posts
    Quote Originally Posted by mwx6205 View Post
    Hi guys,

    I am using Microsoft Access as my database
    Please ensure then that you post in the general database forum, this particular forum is for mysql questions only.

    Thread moved.

  • #3
    New Coder
    Join Date
    Jun 2012
    Posts
    44
    Thanks
    17
    Thanked 0 Times in 0 Posts

    Smile

    Quote Originally Posted by guelphdad View Post
    Please ensure then that you post in the general database forum, this particular forum is for mysql questions only.

    Thread moved.
    Okay. Sorry.

  • #4
    Regular Coder
    Join Date
    Apr 2012
    Location
    St. Louis, MO
    Posts
    985
    Thanks
    7
    Thanked 101 Times in 101 Posts
    I'm not sure I understand your question. Do you want to code something that will replace an automatic increment in the database? Or are you asking about a dynamic server-side language like ASP, PHP, ColdFusion, etc?
    ^_^

    If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
    *
    The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".

  • #5
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Posts
    1,711
    Thanks
    41
    Thanked 191 Times in 190 Posts
    are you using VB macros or a windows form or a webform or ? what is calling the access
    this link is on straight up macros for access DB's- if you are hitting it from a form or web page you will need to hit it with an OLE connection- you can reference it here

    I code C hash-tag .Net
    Reference: W3C W3CWiki .Net Lib
    Validate: html CSS
    Debug: Chrome FireFox IE

  • #6
    New Coder
    Join Date
    Jun 2012
    Posts
    44
    Thanks
    17
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by WolfShade View Post
    I'm not sure I understand your question. Do you want to code something that will replace an automatic increment in the database? Or are you asking about a dynamic server-side language like ASP, PHP, ColdFusion, etc?
    Hi WolfShade,

    I am asking about a dynamic server-side language and I am using PHP + microsoft access as my database.

  • #7
    New Coder
    Join Date
    Jun 2012
    Posts
    44
    Thanks
    17
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by alykins View Post
    are you using VB macros or a windows form or a webform or ? what is calling the access
    this link is on straight up macros for access DB's- if you are hitting it from a form or web page you will need to hit it with an OLE connection- you can reference it here
    Hi alykins,

    So sorry that I can't understand what you mean as I am just a very new incomer.

  • #8
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Posts
    1,711
    Thanks
    41
    Thanked 191 Times in 190 Posts
    You answered my Q in your reply to WolfShade- you are using a php web page to access the database. I don't know php; sry

    The first link I provided though tells you how to make a "stored procedure" in access DB- all you need to do then is call it. Your "hard coded values" would be parameters. So according to their reply you could make something like
    Code:
    CREATE PROCEDURE usp_GetName
    (param1 INT) AS
    SELECT [fName]
    FROM tbl_People
    WHERE id = param1

    I code C hash-tag .Net
    Reference: W3C W3CWiki .Net Lib
    Validate: html CSS
    Debug: Chrome FireFox IE

  • Users who have thanked alykins for this post:

    mwx6205 (07-13-2012)

  • #9
    New Coder
    Join Date
    Jun 2012
    Posts
    44
    Thanks
    17
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by alykins View Post
    You answered my Q in your reply to WolfShade- you are using a php web page to access the database. I don't know php; sry

    The first link I provided though tells you how to make a "stored procedure" in access DB- all you need to do then is call it. Your "hard coded values" would be parameters. So according to their reply you could make something like
    Code:
    CREATE PROCEDURE usp_GetName
    (param1 INT) AS
    SELECT [fName]
    FROM tbl_People
    WHERE id = param1
    Hi alykins,

    Oh I see, okay :P

    Anyway, I need to spend some time to look in deep & thank you so much.

    Cheers,
    mwx6205.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •