Skip to main content
Known Participant
January 15, 2008
Question

Help with ASP Insert Into Command

  • January 15, 2008
  • 1 reply
  • 308 views
Hi All,

I'm trying to get the following command (insert into) to work, but am having
no joy. I would be greatful if you could highlight what i have done wrong.
Its an for an ASP site using an MS SQL database -

<%

if(Session("BATCHID2") <> "") then insertaccountinvoice__MMColParam =
Session("BATCHID2")

if(Session("SITEID") <> "") then insertaccountinvoice__MMColParam2 =
Session("SITEID")

%>
<%
set insertaccountinvoice = Server.CreateObject("ADODB.Command")
insertaccountinvoice.ActiveConnection = MM_recruta2_STRING
insertaccountinvoice.CommandText = "INSERT INTO dbo.JBAccountInvoice
(JBACISiteID, JBACIClientID, JBACIAccountType, JBACIAccountOverwrite,
JBACIBillingContact, JBACIClientName, JBACIClientAddress, JBACIClientEmail,
JBACIBatchID) VALUES (dbo.JBClient(JBCLSiteID, JBCLID, JBCLAccountType,
JBCLreguserMonthlyOverwrite, JBCLBillingContact, JBCLName, JBCLAddress,
JBCLEmail ), " + Replace(insertaccountinvoice__MMColParam, "'", "''") + "
WHERE JBCLSiteID = '" + Replace(insertaccountinvoice__MMColParam2, "'", "''")
+ "' and JBCLAccountLive = 'y' and (JBCLAccountType = 'Reg User' OR
JBCLAccountType = 'Reg User5' OR JBCLAccountType = 'Reg User10' OR
JBCLAccountType = 'Multi User')) "
insertaccountinvoice.CommandType = 1
insertaccountinvoice.CommandTimeout = 0
insertaccountinvoice.Prepared = true
insertaccountinvoice.Execute()
%>
<% Response.Redirect(" http://www.recruta.co.uk") %>
This topic has been closed for replies.

1 reply

Inspiring
January 15, 2008
In general, the syntax for this kind of insert is:

insert into t1 (a,b,c)
select a,b,c from t2 where a=5

--
Jules
http://www.charon.co.uk/products.aspx
Charon Cart
Ecommerce for ASP/ASP.NET