Execute Query in Access from an ASP Form?

Ask a Question related to ASP Components, Design and Development.

  1. #1

    Default Execute Query in Access from an ASP Form?

    Hi,

    I have an Access database with a query that selects a set of records from
    one table (work categories) and inserts them (multiple rows) in to a
    timesheet table, along with the employee's name and selected week number
    (both of which are variables inputted by the user).
    i.e. each record from the employee's chosen work categories gets inserted in
    to a new row in the timesheet table, with their name and chosen week number
    inserted (these are the same for each row in this recordset instance).

    I want to execute this query from an intranet based ASP file, using two text
    boxes and a submit button, but can't get it to work.

    The query works great from within Access (by double clicking), but I am
    having problems defining the code I need to pass the parameters and execute
    the query from the ASP file.

    Has anyone got any ideas on what I can use here?

    Many thanks

    JL


    JL Guest

  2. Similar Questions and Discussions

    1. Execute Query on trigger
      Hi, I want to 2 link to drop down menus together so that the options from the second will be filtered according to the option chose in the first...
    2. How to execute 2 sql commands in one sql query?
      Hello, I need to delete some records and insert new ones right away. Is there any way to do it within the same query string? Set objRecordset =...
    3. How to execute an ADO query asynchronously?
      Is this a valid code (running in a COM+ component)? VB class (MTSTransactionMode = 1 - NoTransactions): Private Declare Sub Sleep Lib...
    4. how to execute the query with special character
      hello, i am using command window on db2 udb v8.1 on windows to query a table with field name like this select abc\ from table, but i get the error...
    5. Cannot execute dynamic query in stored procedure
      Hi, I'm using ADO.NET to execute a stored proc. The stored proc contains a dynamic sql which will build the INSERT or UPDATE statement for...
  3. #2

    Default Execute Query in Access from an ASP Form?

    Hi,

    I have an Access database with a query that selects a set of records from
    one table (work categories) and inserts them (multiple rows) in to a
    timesheet table, along with the employee's name and selected week number
    (both of which are variables inputted by the user).
    i.e. each record from the employee's chosen work categories gets inserted in
    to a new row in the timesheet table, with their name and chosen week number
    inserted (these are the same for each row in this recordset instance).

    I want to execute this query from an intranet based ASP file, using two text
    boxes and a submit button, but can't get it to work.

    The query works great from within Access (by double clicking), but I am
    having problems defining the code I need to pass the parameters and execute
    the query from the ASP file.

    Has anyone got any ideas on what I can use here?

    Many thanks

    JL


    JL Guest

  4. #3

    Default Re: Execute Query in Access from an ASP Form?

    JL,
    Post the code you have tried
    "JL" <design4online@REMOVETHISBIThotmail.com> wrote in message
    news:l3YMa.503$PK2.151@newsfep1-gui.server.ntli.net...
    > Hi,
    >
    > I have an Access database with a query that selects a set of records from
    > one table (work categories) and inserts them (multiple rows) in to a
    > timesheet table, along with the employee's name and selected week number
    > (both of which are variables inputted by the user).
    > i.e. each record from the employee's chosen work categories gets inserted
    in
    > to a new row in the timesheet table, with their name and chosen week
    number
    > inserted (these are the same for each row in this recordset instance).
    >
    > I want to execute this query from an intranet based ASP file, using two
    text
    > boxes and a submit button, but can't get it to work.
    >
    > The query works great from within Access (by double clicking), but I am
    > having problems defining the code I need to pass the parameters and
    execute
    > the query from the ASP file.
    >
    > Has anyone got any ideas on what I can use here?
    >
    > Many thanks
    >
    > JL
    >
    >

    solex Guest

  5. #4

    Default Re: Execute Query in Access from an ASP Form?

    JL,
    Post the code you have tried
    "JL" <design4online@REMOVETHISBIThotmail.com> wrote in message
    news:l3YMa.503$PK2.151@newsfep1-gui.server.ntli.net...
    > Hi,
    >
    > I have an Access database with a query that selects a set of records from
    > one table (work categories) and inserts them (multiple rows) in to a
    > timesheet table, along with the employee's name and selected week number
    > (both of which are variables inputted by the user).
    > i.e. each record from the employee's chosen work categories gets inserted
    in
    > to a new row in the timesheet table, with their name and chosen week
    number
    > inserted (these are the same for each row in this recordset instance).
    >
    > I want to execute this query from an intranet based ASP file, using two
    text
    > boxes and a submit button, but can't get it to work.
    >
    > The query works great from within Access (by double clicking), but I am
    > having problems defining the code I need to pass the parameters and
    execute
    > the query from the ASP file.
    >
    > Has anyone got any ideas on what I can use here?
    >
    > Many thanks
    >
    > JL
    >
    >

    solex Guest

  6. #5

    Default Re: Execute Query in Access from an ASP Form?

    Without details, I can only give a generic solution:
    1. Assign the values from the Request object to variables and validate them:

    dim empName, wkNumber
    empName=Request.Form("txtEmpName")
    If len(empName) = 0 then
    response.write "Empty Employee Name"
    Or
    redirect to error page
    end if
    wkNumber = Request.Form("txtWeekNumber")
    If len(empName) = 0 then
    response.write "No Week Number provided"
    Or
    redirect to error page
    end if
    on error resume next
    wkNumber = CInt(wkNumber)
    if err <> 0 then
    response.write "Week Number was not supplied numerically"
    Or
    redirect to error page
    end if

    2.Create and open a connection object, cn:

    dim cn
    set cn=server.createobject(adodb.connection")
    cn.open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "p:\ath\to\database.mdb"

    3. Run the query (assume it's called qAddRecords, and the parameters are
    defined in this order: employee name, then week number):
    cn.qAddRecords empName, wkNumber

    4. handle errors
    5. then close and destroy the connection:
    cn.close
    set cn = nothing

    HTH,
    Bob Barrows


    JL wrote:
    > Hi,
    >
    > I have an Access database with a query that selects a set of records
    > from one table (work categories) and inserts them (multiple rows) in
    > to a timesheet table, along with the employee's name and selected
    > week number (both of which are variables inputted by the user).
    > i.e. each record from the employee's chosen work categories gets
    > inserted in to a new row in the timesheet table, with their name and
    > chosen week number inserted (these are the same for each row in this
    > recordset instance).
    >
    > I want to execute this query from an intranet based ASP file, using
    > two text boxes and a submit button, but can't get it to work.
    >
    > The query works great from within Access (by double clicking), but I
    > am having problems defining the code I need to pass the parameters
    > and execute the query from the ASP file.
    >
    > Has anyone got any ideas on what I can use here?
    >
    > Many thanks
    >
    > JL

    Bob Barrows Guest

  7. #6

    Default Re: Execute Query in Access from an ASP Form?

    Without details, I can only give a generic solution:
    1. Assign the values from the Request object to variables and validate them:

    dim empName, wkNumber
    empName=Request.Form("txtEmpName")
    If len(empName) = 0 then
    response.write "Empty Employee Name"
    Or
    redirect to error page
    end if
    wkNumber = Request.Form("txtWeekNumber")
    If len(empName) = 0 then
    response.write "No Week Number provided"
    Or
    redirect to error page
    end if
    on error resume next
    wkNumber = CInt(wkNumber)
    if err <> 0 then
    response.write "Week Number was not supplied numerically"
    Or
    redirect to error page
    end if

    2.Create and open a connection object, cn:

    dim cn
    set cn=server.createobject(adodb.connection")
    cn.open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "p:\ath\to\database.mdb"

    3. Run the query (assume it's called qAddRecords, and the parameters are
    defined in this order: employee name, then week number):
    cn.qAddRecords empName, wkNumber

    4. handle errors
    5. then close and destroy the connection:
    cn.close
    set cn = nothing

    HTH,
    Bob Barrows


    JL wrote:
    > Hi,
    >
    > I have an Access database with a query that selects a set of records
    > from one table (work categories) and inserts them (multiple rows) in
    > to a timesheet table, along with the employee's name and selected
    > week number (both of which are variables inputted by the user).
    > i.e. each record from the employee's chosen work categories gets
    > inserted in to a new row in the timesheet table, with their name and
    > chosen week number inserted (these are the same for each row in this
    > recordset instance).
    >
    > I want to execute this query from an intranet based ASP file, using
    > two text boxes and a submit button, but can't get it to work.
    >
    > The query works great from within Access (by double clicking), but I
    > am having problems defining the code I need to pass the parameters
    > and execute the query from the ASP file.
    >
    > Has anyone got any ideas on what I can use here?
    >
    > Many thanks
    >
    > JL

    Bob Barrows Guest

  8. #7

    Default Re: Execute Query in Access from an ASP Form?

    Hi,

    Thanks for the interest.

    Here is the code I am using for the insert query:

    INSERT INTO TimeSheets ( Eng, JobID, JobName, WeekNo, SunDate, MonDate,
    TueDate, WedDate, ThuDate, FriDate, SatDate )
    SELECT E.Engineer, E.JobId, E.JobName, W.WkNo, [Year2003], ([Year2003]+1),
    ([Year2003]+2), ([Year2003]+3), ([Year2003]+4), ([Year2003]+5),
    ([Year2003]+6)
    FROM EngJobs AS E, WeekNos AS W
    WHERE Engineer=txtEng And WkNo=txtWkNo;

    Each record is for 1 week of each project chosen and looks up the relevant
    dates from a table for the chosen week number.
    What I am looking for is the code I would use in an ASP form (2 text boxes -
    'txtEng' and 'txtWkNo' with a submit button) to get the query to run from
    the browser.

    Thanks

    JL




    "solex" <solex@nowhere.com> wrote in message
    news:u0Smi0XQDHA.1712@TK2MSFTNGP12.phx.gbl...
    > JL,
    > Post the code you have tried
    > "JL" <design4online@REMOVETHISBIThotmail.com> wrote in message
    > news:l3YMa.503$PK2.151@newsfep1-gui.server.ntli.net...
    > > Hi,
    > >
    > > I have an Access database with a query that selects a set of records
    from
    > > one table (work categories) and inserts them (multiple rows) in to a
    > > timesheet table, along with the employee's name and selected week number
    > > (both of which are variables inputted by the user).
    > > i.e. each record from the employee's chosen work categories gets
    inserted
    > in
    > > to a new row in the timesheet table, with their name and chosen week
    > number
    > > inserted (these are the same for each row in this recordset instance).
    > >
    > > I want to execute this query from an intranet based ASP file, using two
    > text
    > > boxes and a submit button, but can't get it to work.
    > >
    > > The query works great from within Access (by double clicking), but I am
    > > having problems defining the code I need to pass the parameters and
    > execute
    > > the query from the ASP file.
    > >
    > > Has anyone got any ideas on what I can use here?
    > >
    > > Many thanks
    > >
    > > JL
    > >
    > >
    >
    >

    JL Guest

  9. #8

    Default Re: Execute Query in Access from an ASP Form?

    Hi,

    Thanks for the interest.

    Here is the code I am using for the insert query:

    INSERT INTO TimeSheets ( Eng, JobID, JobName, WeekNo, SunDate, MonDate,
    TueDate, WedDate, ThuDate, FriDate, SatDate )
    SELECT E.Engineer, E.JobId, E.JobName, W.WkNo, [Year2003], ([Year2003]+1),
    ([Year2003]+2), ([Year2003]+3), ([Year2003]+4), ([Year2003]+5),
    ([Year2003]+6)
    FROM EngJobs AS E, WeekNos AS W
    WHERE Engineer=txtEng And WkNo=txtWkNo;

    Each record is for 1 week of each project chosen and looks up the relevant
    dates from a table for the chosen week number.
    What I am looking for is the code I would use in an ASP form (2 text boxes -
    'txtEng' and 'txtWkNo' with a submit button) to get the query to run from
    the browser.

    Thanks

    JL




    "solex" <solex@nowhere.com> wrote in message
    news:u0Smi0XQDHA.1712@TK2MSFTNGP12.phx.gbl...
    > JL,
    > Post the code you have tried
    > "JL" <design4online@REMOVETHISBIThotmail.com> wrote in message
    > news:l3YMa.503$PK2.151@newsfep1-gui.server.ntli.net...
    > > Hi,
    > >
    > > I have an Access database with a query that selects a set of records
    from
    > > one table (work categories) and inserts them (multiple rows) in to a
    > > timesheet table, along with the employee's name and selected week number
    > > (both of which are variables inputted by the user).
    > > i.e. each record from the employee's chosen work categories gets
    inserted
    > in
    > > to a new row in the timesheet table, with their name and chosen week
    > number
    > > inserted (these are the same for each row in this recordset instance).
    > >
    > > I want to execute this query from an intranet based ASP file, using two
    > text
    > > boxes and a submit button, but can't get it to work.
    > >
    > > The query works great from within Access (by double clicking), but I am
    > > having problems defining the code I need to pass the parameters and
    > execute
    > > the query from the ASP file.
    > >
    > > Has anyone got any ideas on what I can use here?
    > >
    > > Many thanks
    > >
    > > JL
    > >
    > >
    >
    >

    JL Guest

  10. #9

    Default Re: Execute Query in Access from an ASP Form?

    Hi JL

    Are we talking standard HTML/ASP rather than Access ADP here? If so, then
    you need some server-side routine to run your insert query.. Exactly how
    this is done will depend on the Method and Action you've specified for your
    HTLM Form. The query *cannot* be run directly from the client side. Might
    I recommend one of the "Programmer to Programmer" books published by Wrox
    press "Active Server Pages 3.0", Homer et al and Osborne's "The Complete
    Reference HTML", T A Powell

    HTH

    Andy

    "JL" <design4online@REMOVETHISBIThotmail.com> wrote in message
    news:Pe6Na.1115$PK2.772@newsfep1-gui.server.ntli.net...
    > Hi,
    >
    > Thanks for the interest.
    >
    > Here is the code I am using for the insert query:
    >
    > INSERT INTO TimeSheets ( Eng, JobID, JobName, WeekNo, SunDate, MonDate,
    > TueDate, WedDate, ThuDate, FriDate, SatDate )
    > SELECT E.Engineer, E.JobId, E.JobName, W.WkNo, [Year2003], ([Year2003]+1),
    > ([Year2003]+2), ([Year2003]+3), ([Year2003]+4), ([Year2003]+5),
    > ([Year2003]+6)
    > FROM EngJobs AS E, WeekNos AS W
    > WHERE Engineer=txtEng And WkNo=txtWkNo;
    >
    > Each record is for 1 week of each project chosen and looks up the relevant
    > dates from a table for the chosen week number.
    > What I am looking for is the code I would use in an ASP form (2 text
    boxes -
    > 'txtEng' and 'txtWkNo' with a submit button) to get the query to run from
    > the browser.
    >
    > Thanks
    >
    > JL
    >
    >
    >
    >
    > "solex" <solex@nowhere.com> wrote in message
    > news:u0Smi0XQDHA.1712@TK2MSFTNGP12.phx.gbl...
    > > JL,
    > > Post the code you have tried
    > > "JL" <design4online@REMOVETHISBIThotmail.com> wrote in message
    > > news:l3YMa.503$PK2.151@newsfep1-gui.server.ntli.net...
    > > > Hi,
    > > >
    > > > I have an Access database with a query that selects a set of records
    > from
    > > > one table (work categories) and inserts them (multiple rows) in to a
    > > > timesheet table, along with the employee's name and selected week
    number
    > > > (both of which are variables inputted by the user).
    > > > i.e. each record from the employee's chosen work categories gets
    > inserted
    > > in
    > > > to a new row in the timesheet table, with their name and chosen week
    > > number
    > > > inserted (these are the same for each row in this recordset instance).
    > > >
    > > > I want to execute this query from an intranet based ASP file, using
    two
    > > text
    > > > boxes and a submit button, but can't get it to work.
    > > >
    > > > The query works great from within Access (by double clicking), but I
    am
    > > > having problems defining the code I need to pass the parameters and
    > > execute
    > > > the query from the ASP file.
    > > >
    > > > Has anyone got any ideas on what I can use here?
    > > >
    > > > Many thanks
    > > >
    > > > JL
    > > >
    > > >
    > >
    > >
    >
    >

    Andy Cole Guest

  11. #10

    Default Re: Execute Query in Access from an ASP Form?

    Hi JL

    Are we talking standard HTML/ASP rather than Access ADP here? If so, then
    you need some server-side routine to run your insert query.. Exactly how
    this is done will depend on the Method and Action you've specified for your
    HTLM Form. The query *cannot* be run directly from the client side. Might
    I recommend one of the "Programmer to Programmer" books published by Wrox
    press "Active Server Pages 3.0", Homer et al and Osborne's "The Complete
    Reference HTML", T A Powell

    HTH

    Andy

    "JL" <design4online@REMOVETHISBIThotmail.com> wrote in message
    news:Pe6Na.1115$PK2.772@newsfep1-gui.server.ntli.net...
    > Hi,
    >
    > Thanks for the interest.
    >
    > Here is the code I am using for the insert query:
    >
    > INSERT INTO TimeSheets ( Eng, JobID, JobName, WeekNo, SunDate, MonDate,
    > TueDate, WedDate, ThuDate, FriDate, SatDate )
    > SELECT E.Engineer, E.JobId, E.JobName, W.WkNo, [Year2003], ([Year2003]+1),
    > ([Year2003]+2), ([Year2003]+3), ([Year2003]+4), ([Year2003]+5),
    > ([Year2003]+6)
    > FROM EngJobs AS E, WeekNos AS W
    > WHERE Engineer=txtEng And WkNo=txtWkNo;
    >
    > Each record is for 1 week of each project chosen and looks up the relevant
    > dates from a table for the chosen week number.
    > What I am looking for is the code I would use in an ASP form (2 text
    boxes -
    > 'txtEng' and 'txtWkNo' with a submit button) to get the query to run from
    > the browser.
    >
    > Thanks
    >
    > JL
    >
    >
    >
    >
    > "solex" <solex@nowhere.com> wrote in message
    > news:u0Smi0XQDHA.1712@TK2MSFTNGP12.phx.gbl...
    > > JL,
    > > Post the code you have tried
    > > "JL" <design4online@REMOVETHISBIThotmail.com> wrote in message
    > > news:l3YMa.503$PK2.151@newsfep1-gui.server.ntli.net...
    > > > Hi,
    > > >
    > > > I have an Access database with a query that selects a set of records
    > from
    > > > one table (work categories) and inserts them (multiple rows) in to a
    > > > timesheet table, along with the employee's name and selected week
    number
    > > > (both of which are variables inputted by the user).
    > > > i.e. each record from the employee's chosen work categories gets
    > inserted
    > > in
    > > > to a new row in the timesheet table, with their name and chosen week
    > > number
    > > > inserted (these are the same for each row in this recordset instance).
    > > >
    > > > I want to execute this query from an intranet based ASP file, using
    two
    > > text
    > > > boxes and a submit button, but can't get it to work.
    > > >
    > > > The query works great from within Access (by double clicking), but I
    am
    > > > having problems defining the code I need to pass the parameters and
    > > execute
    > > > the query from the ASP file.
    > > >
    > > > Has anyone got any ideas on what I can use here?
    > > >
    > > > Many thanks
    > > >
    > > > JL
    > > >
    > > >
    > >
    > >
    >
    >

    Andy Cole Guest

  12. #11

    Default Re: Execute Query in Access from an ASP Form?

    "JL" <design4online@REMOVETHISBIThotmail.com> wrote in message
    news:l3YMa.503$PK2.151@newsfep1-gui.server.ntli.net...
    > Hi,
    >
    > I have an Access database with a query that selects a set of records from
    > one table (work categories) and inserts them (multiple rows) in to a
    > timesheet table, along with the employee's name and selected week number
    > (both of which are variables inputted by the user).
    > i.e. each record from the employee's chosen work categories gets inserted
    in
    > to a new row in the timesheet table, with their name and chosen week
    number
    > inserted (these are the same for each row in this recordset instance).
    >
    > I want to execute this query from an intranet based ASP file, using two
    text
    > boxes and a submit button, but can't get it to work.
    >
    > The query works great from within Access (by double clicking), but I am
    > having problems defining the code I need to pass the parameters and
    execute
    > the query from the ASP file.
    >
    > Has anyone got any ideas on what I can use here?
    >
    > Many thanks
    >
    > JL
    >
    >
    The semi colon at the end of the statement could cause you some grief

    cm


    Clive Moss Guest

  13. #12

    Default Re: Execute Query in Access from an ASP Form?

    "JL" <design4online@REMOVETHISBIThotmail.com> wrote in message
    news:l3YMa.503$PK2.151@newsfep1-gui.server.ntli.net...
    > Hi,
    >
    > I have an Access database with a query that selects a set of records from
    > one table (work categories) and inserts them (multiple rows) in to a
    > timesheet table, along with the employee's name and selected week number
    > (both of which are variables inputted by the user).
    > i.e. each record from the employee's chosen work categories gets inserted
    in
    > to a new row in the timesheet table, with their name and chosen week
    number
    > inserted (these are the same for each row in this recordset instance).
    >
    > I want to execute this query from an intranet based ASP file, using two
    text
    > boxes and a submit button, but can't get it to work.
    >
    > The query works great from within Access (by double clicking), but I am
    > having problems defining the code I need to pass the parameters and
    execute
    > the query from the ASP file.
    >
    > Has anyone got any ideas on what I can use here?
    >
    > Many thanks
    >
    > JL
    >
    >
    The semi colon at the end of the statement could cause you some grief

    cm


    Clive Moss Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139