How to execute 2 sql commands in one sql query?

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

  1. #1

    Default 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 = Server.CreateObject("ADODB.Recordset")
    QueryString = "delete from Tbl_Therapy where proceduredate
    = 06/02/04; insert into tbl_therapy(caseid, procedureid,
    proceduredate) values(1, 99203, 06/03/04);"

    Something of this nature.
    It is giving me following error:
    Error Type:
    Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
    [Microsoft][ODBC Microsoft Access Driver] Characters found
    after end of SQL statement.

    Please help.
    Thank you in advance.




    Vlad 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. Unable to execute shell commands
      Windows 2003 ISS 6.0 That's your problem ;) try using: Linux Debain Apache 1.3 Then it will execute the shell commands. windows does not...
    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. WScript.Shell to execute Ms-DOS commands?
      Good morning everybody, How can I use WScript.Shell to execute Ms-DOS commands and can I see the outputs commands in the asp page? In the...
    5. DDE Execute Wordpad Commands
      I am opening a text document in Wordpad and attempting to use "Send DDE Execute" to "Select All" text and "Copy" within Wordpad. This would enble...
  3. #2

    Default Re: How to execute 2 sql commands in one sql query?

    Vlad wrote:
    > 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?
    No. Jet does not support batch execution of sql statements..
    >
    > Set objRecordset = Server.CreateObject("ADODB.Recordset")
    What is the reason for this recordset object? It does not appear that you
    are planning to return records from this query. Why create an expensive
    recordset object?
    > QueryString = "delete from Tbl_Therapy where proceduredate
    > = 06/02/04; insert into tbl_therapy(caseid, procedureid,
    > proceduredate) values(1, 99203, 06/03/04);"
    >
    > Something of this nature.
    > It is giving me following error:
    > Error Type:
    > Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
    > [Microsoft][ODBC Microsoft Access Driver] Characters found
    > after end of SQL statement.
    >
    Nothing to do with your problem, but you should switch to using the native
    Jet OLEDB provider rather than the ODBC provider. See
    [url]www.able-consulting.com/ado_conn.htm[/url] for examples connection strings using
    the Provider for Microsoft Jet.

    Bob Barrows
    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"


    Bob Barrows [MVP] Guest

  4. #3

    Default Re: How to execute 2 sql commands in one sql query?

    Bob Barrows [MVP] wrote:
    > Vlad wrote:
    >
    >>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?
    >
    >
    > No. Jet does not support batch execution of sql statements..
    >
    >
    >>Set objRecordset = Server.CreateObject("ADODB.Recordset")
    >
    >
    > What is the reason for this recordset object? It does not appear that you
    > are planning to return records from this query. Why create an expensive
    > recordset object?
    >
    >
    >>QueryString = "delete from Tbl_Therapy where proceduredate
    >>= 06/02/04; insert into tbl_therapy(caseid, procedureid,
    >>proceduredate) values(1, 99203, 06/03/04);"
    >
    >
    >
    >>Something of this nature.
    >>It is giving me following error:
    >>Error Type:
    >>Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
    >>[Microsoft][ODBC Microsoft Access Driver] Characters found
    >>after end of SQL statement.
    >>
    >
    >
    > Nothing to do with your problem, but you should switch to using the native
    > Jet OLEDB provider rather than the ODBC provider. See
    > [url]www.able-consulting.com/ado_conn.htm[/url] for examples connection strings using
    > the Provider for Microsoft Jet.
    >
    > Bob Barrows
    what's the benifit of using native Jet OleDB provider rather than the
    ODBC provider if it's just a simple asp page?
    nick Guest

  5. #4

    Default Re: How to execute 2 sql commands in one sql query?

    nick wrote:
    >
    > what's the benifit of using native Jet OleDB provider rather than the
    > ODBC provider if it's just a simple asp page?
    Excuse me? Are you saying that you think it's all right to use inefficient,
    obsolete techniques on simple pages, but not all right on more complex
    pages? This does not compute.

    IMO, there's no such thing as a "simple asp page". Don't forget: your
    "simple asp page" is probably running on a web server that delivers other
    asp pages, both simple and complex, as well as html pages.
    Threading,performance, and robustness must be considered in this
    environment. An inefficient simple asp page that gets called millions of
    times will probably perform adequately when viewed in isolation, but may
    have a severe impact on the other pages and applications being served by
    your web server.

    MS has deprecated the OLEDB Provider for ODBC drivers (MSDASQL). This means
    that new functionality, perfiormance and stability enhancements, etc. that
    will be incorporated in new versions of native OLEDB providers will possibly
    be left out of the MSDASQL provider.
    [url]http://msdn.microsoft.com/library/en-us/ado270/htm/ado_deprecated_components.asp[/url]

    HTH,
    Bob Barrows
    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.


    Bob Barrows [MVP] Guest

  6. #5

    Default Re: How to execute 2 sql commands in one sql query?

    So, what is the way to do if I need to delete some
    recordes and then insert the new ones right away?
    Using objRset.delete, objRsetAddNew and objRset.update?
    Or perhaps stored procedure? But this is an Access and I
    am not sure how to do it in Access. Any samples or links?
    Thank you.
    >-----Original Message-----
    >nick wrote:
    >>
    >> what's the benifit of using native Jet OleDB provider
    rather than the
    >> ODBC provider if it's just a simple asp page?
    >
    >Excuse me? Are you saying that you think it's all right
    to use inefficient,
    >obsolete techniques on simple pages, but not all right on
    more complex
    >pages? This does not compute.
    >
    >IMO, there's no such thing as a "simple asp page". Don't
    forget: your
    >"simple asp page" is probably running on a web server
    that delivers other
    >asp pages, both simple and complex, as well as html pages.
    >Threading,performance, and robustness must be considered
    in this
    >environment. An inefficient simple asp page that gets
    called millions of
    >times will probably perform adequately when viewed in
    isolation, but may
    >have a severe impact on the other pages and applications
    being served by
    >your web server.
    >
    >MS has deprecated the OLEDB Provider for ODBC drivers
    (MSDASQL). This means
    >that new functionality, perfiormance and stability
    enhancements, etc. that
    >will be incorporated in new versions of native OLEDB
    providers will possibly
    >be left out of the MSDASQL provider.
    >[url]http://msdn.microsoft.com/library/en-[/url]
    us/ado270/htm/ado_deprecated_components.asp
    >
    >HTH,
    >Bob Barrows
    >--
    >Microsoft MVP -- ASP/ASP.NET
    >Please reply to the newsgroup. The email account listed
    in my From
    >header is my spam trap, so I don't check it very often.
    You will get a
    >quicker response by posting to the newsgroup.
    >
    >
    >.
    >
    Guest

  7. #6

    Default Re: How to execute 2 sql commands in one sql query?

    Are you nick?

    [email]anonymous@discussions.microsoft.com[/email] wrote:
    > So, what is the way to do if I need to delete some
    > recordes and then insert the new ones right away?
    Just perform two executions.

    QueryString = "delete from Tbl_Therapy " & _
    "where proceduredate= #06/02/04#; "
    conn.Execute QueryString,,129

    QueryString = "insert into tbl_therapy(caseid, " & _
    "procedureid,proceduredate) " & _
    "values(1, 99203, #06/03/04#);"
    conn.Execute QueryString,,129

    > Using objRset.delete, objRsetAddNew and objRset.update?
    No.
    > Or perhaps stored procedure? But this is an Access and I
    > am not sure how to do it in Access. Any samples or links?
    Search Google for posts by me containing the words "saved parameter
    queries". I have posted information about this many times.
    Unfortunately, even this technique (saved parameter queries) will not save
    you from having to perform two executions. If you upgrade to SQL Server, you
    will get the benefit of batch execution and stored procedures.
    > Thank you.
    You're welcome.
    Bob Barrows

    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.


    Bob Barrows [MVP] Guest

  8. #7

    Default Re: How to execute 2 sql commands in one sql query?

    "Bob Barrows [MVP]" wrote in message
    news:eKhoV5GVEHA.3332@tk2msftngp13.phx.gbl...
    : nick wrote:
    : >
    : > what's the benifit of using native Jet OleDB provider rather than the
    : > ODBC provider if it's just a simple asp page?
    :
    : Excuse me? Are you saying that you think it's all right to use
    inefficient,
    : obsolete techniques on simple pages, but not all right on more complex
    : pages? This does not compute.

    Adding this to my list of "Questions Not To Ask" a.k.a. "How to Tick Off Bob
    in One Easy Question". (O:=

    --
    Roland Hall
    /* This information is distributed in the hope that it will be useful, but
    without any warranty; without even the implied warranty of merchantability
    or fitness for a particular purpose. */
    Technet Script Center - [url]http://www.microsoft.com/technet/scriptcenter/[/url]
    WSH 5.6 Documentation - [url]http://msdn.microsoft.com/downloads/list/webdev.asp[/url]
    MSDN Library - [url]http://msdn.microsoft.com/library/default.asp[/url]



    Roland Hall Guest

  9. #8

    Default Re: How to execute 2 sql commands in one sql query?

    Roland Hall wrote:
    > "Bob Barrows [MVP]" wrote in message
    > news:eKhoV5GVEHA.3332@tk2msftngp13.phx.gbl...
    >> nick wrote:
    >>>
    >>> what's the benifit of using native Jet OleDB provider rather than
    >>> the ODBC provider if it's just a simple asp page?
    >>
    >> Excuse me? Are you saying that you think it's all right to use
    >> inefficient, obsolete techniques on simple pages, but not all right
    >> on more complex pages? This does not compute.
    >
    > Adding this to my list of "Questions Not To Ask" a.k.a. "How to Tick
    > Off Bob in One Easy Question". (O:=
    :-)

    I wasn't ticked off, but you're right: it does look like I was ticked off.
    Believe it or not, I was chuckling as I wrote it. As I reread it, it's easy
    to imagine myself snarling ...

    Bob Barrows
    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.


    Bob Barrows [MVP] Guest

  10. #9

    Default Re: How to execute 2 sql commands in one sql query?

    "Bob Barrows [MVP]" wrote in message
    news:uI543QKVEHA.1036@TK2MSFTNGP12.phx.gbl...
    : Roland Hall wrote:
    : > "Bob Barrows [MVP]" wrote in message
    : > news:eKhoV5GVEHA.3332@tk2msftngp13.phx.gbl...
    : >> nick wrote:
    : >>>
    : >>> what's the benifit of using native Jet OleDB provider rather than
    : >>> the ODBC provider if it's just a simple asp page?
    : >>
    : >> Excuse me? Are you saying that you think it's all right to use
    : >> inefficient, obsolete techniques on simple pages, but not all right
    : >> on more complex pages? This does not compute.
    : >
    : > Adding this to my list of "Questions Not To Ask" a.k.a. "How to Tick
    : > Off Bob in One Easy Question". (O:=
    :
    : :-)
    :
    : I wasn't ticked off, but you're right: it does look like I was ticked off.
    : Believe it or not, I was chuckling as I wrote it. As I reread it, it's
    easy
    : to imagine myself snarling ...

    I thought you handled it well. The analogous question made me laugh out
    loud.


    Roland Hall 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