Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: Multiple Insert into database


Message #1 by "Savonnya D. Rodrigues" <srod@f...> on Thu, 18 Jan 2001 09:59:41 -0600
I am trying to insert to tables into my database. I tested each one, one by

one, and their was no error. When I tried to run them at the same. It just

ran one of them. Is their a way you can run them both together. I attached

my code. Can you help me?



'Build the insert string



strSQL = "Insert into Software (LicenseKeyNum, ProductID, " &

"ServerApplication, InstalledBy, Manufacture, ProductName, Version,

Description, Status, UserID, Comment) " & "Values('" &

Request.Form("txtLicenseKeyNum") & "','" & Request.Form("txtProductID") &

"','" & Request.Form("txtServerApplication") & "','" &

Request.Form("txtInstalledBy") & "','" & Request.Form("txtManufacture") &

"','" & Request.Form("txtProductName") & "','" & Request.Form("txtVersion")

& "','" & Request.Form("txtDescription") & "','" & Request.Form("txtStatus")

& "','" & Request.Form("txtUserID") & "','" & Request.Form("txtComment") &

"')"



strSQL = "Insert into PurchaseOrder (POComment,PCQuote , " & "DateReceived,

DateApproved,Cost, MaintenanceAgree, LicenseLocation) " & "Values('" &

Request.Form("txtPOComment") & "','" & Request.Form("txtPCQuote") & "'," &

Cdate(Request.Form("txtDateReceived")) & "," &

Cdate(Request.Form("txtDateApproved")) & "," & Request.Form("txtCost") &

",'" & Request.Form("txtMaintenanceAgree") & "','" &

Request.Form("txtLicenseLocation") & "')"





'Create and open the database object



Set objConn = Server.CreateObject("ADODB.Connection")



objConn.Open "DSN=ESS"



'Create the command object



Set objCmd = Server.CreateObject("ADODB.Command")



'Set the command object properties



Set objCmd.ActiveConnection = objConn



objCmd.CommandText = strSQL



objCmd.CommandType = adCmdText



'Execute the command



objCmd.Execute



'Display the insert string



Response.Write "The following insert string was executed and" & "the values

inserted into Software.<P>"



Response.Write strSQL



'Close and dereference database objects



Set objCmd = Nothing



objConn.Close



Set objConn = Nothing



Message #2 by "Wally Burfine" <oopconsultant@h...> on Thu, 18 Jan 2001 16:46:08 -0000
looks to me like you are setting a variable to an sql statement then

setting the same variable to a different sql statement.





>From: "Savonnya D. Rodrigues" <srod@f...>

>Reply-To: "ASP Databases" <asp_databases@p...>

>To: "ASP Databases" <asp_databases@p...>

>Subject: [asp_databases] Multiple Insert into database

>Date: Thu, 18 Jan 2001 09:59:41 -0600

>

>I am trying to insert to tables into my database. I tested each one, one by

>one, and their was no error. When I tried to run them at the same. It just

>ran one of them. Is their a way you can run them both together. I attached

>my code. Can you help me?

>

>'Build the insert string

>

>strSQL = "Insert into Software (LicenseKeyNum, ProductID, " &

>"ServerApplication, InstalledBy, Manufacture, ProductName, Version,

>Description, Status, UserID, Comment) " & "Values('" &

>Request.Form("txtLicenseKeyNum") & "','" & Request.Form("txtProductID") &

>"','" & Request.Form("txtServerApplication") & "','" &

>Request.Form("txtInstalledBy") & "','" & Request.Form("txtManufacture") &

>"','" & Request.Form("txtProductName") & "','" & Request.Form("txtVersion")

>& "','" & Request.Form("txtDescription") & "','" & 

>Request.Form("txtStatus")

>& "','" & Request.Form("txtUserID") & "','" & Request.Form("txtComment") &

>"')"

>

>strSQL = "Insert into PurchaseOrder (POComment,PCQuote , " & "DateReceived,

>DateApproved,Cost, MaintenanceAgree, LicenseLocation) " & "Values('" &

>Request.Form("txtPOComment") & "','" & Request.Form("txtPCQuote") & "'," &

>Cdate(Request.Form("txtDateReceived")) & "," &

>Cdate(Request.Form("txtDateApproved")) & "," & Request.Form("txtCost") &

>",'" & Request.Form("txtMaintenanceAgree") & "','" &

>Request.Form("txtLicenseLocation") & "')"

>

>

>'Create and open the database object

>

>Set objConn = Server.CreateObject("ADODB.Connection")

>

>objConn.Open "DSN=ESS"

>

>'Create the command object

>

>Set objCmd = Server.CreateObject("ADODB.Command")

>

>'Set the command object properties

>

>Set objCmd.ActiveConnection = objConn

>

>objCmd.CommandText = strSQL

>

>objCmd.CommandType = adCmdText

>

>'Execute the command

>

>objCmd.Execute

>

>'Display the insert string

>

>Response.Write "The following insert string was executed and" & "the values

>inserted into Software.<P>"

>

>Response.Write strSQL

>

>'Close and dereference database objects

>

>Set objCmd = Nothing

>

>objConn.Close

>

>Set objConn = Nothing

>

Message #3 by =?iso-8859-1?Q?H=E5kan_Frennesson?= <hakan@c...> on Thu, 18 Jan 2001 17:52:36 +0100
Just a quick remark...you have the same name (strSQL) on the two

strings..how does the script know which one to process?



Hakan



-----Original Message-----

From: Savonnya D. Rodrigues [mailto:srod@f...]

Sent: den 18 januari 2001 17:00

To: ASP Databases

Subject: [asp_databases] Multiple Insert into database



I am trying to insert to tables into my database. I tested each one, one by

one, and their was no error. When I tried to run them at the same. It just

ran one of them. Is their a way you can run them both together. I attached

my code. Can you help me?



'Build the insert string



strSQL = "Insert into Software (LicenseKeyNum, ProductID, " &

"ServerApplication, InstalledBy, Manufacture, ProductName, Version,

Description, Status, UserID, Comment) " & "Values('" &

Request.Form("txtLicenseKeyNum") & "','" & Request.Form("txtProductID") &

"','" & Request.Form("txtServerApplication") & "','" &

Request.Form("txtInstalledBy") & "','" & Request.Form("txtManufacture") &

"','" & Request.Form("txtProductName") & "','" & Request.Form("txtVersion")

& "','" & Request.Form("txtDescription") & "','" & Request.Form("txtStatus")

& "','" & Request.Form("txtUserID") & "','" & Request.Form("txtComment") &

"')"



strSQL = "Insert into PurchaseOrder (POComment,PCQuote , " & "DateReceived,

DateApproved,Cost, MaintenanceAgree, LicenseLocation) " & "Values('" &

Request.Form("txtPOComment") & "','" & Request.Form("txtPCQuote") & "'," &

Cdate(Request.Form("txtDateReceived")) & "," &

Cdate(Request.Form("txtDateApproved")) & "," & Request.Form("txtCost") &

",'" & Request.Form("txtMaintenanceAgree") & "','" &

Request.Form("txtLicenseLocation") & "')"





'Create and open the database object



Set objConn = Server.CreateObject("ADODB.Connection")



objConn.Open "DSN=ESS"



'Create the command object



Set objCmd = Server.CreateObject("ADODB.Command")



'Set the command object properties



Set objCmd.ActiveConnection = objConn



objCmd.CommandText = strSQL



objCmd.CommandType = adCmdText



'Execute the command



objCmd.Execute



'Display the insert string



Response.Write "The following insert string was executed and" & "the values

inserted into Software.<P>"



Response.Write strSQL



'Close and dereference database objects



Set objCmd = Nothing



objConn.Close



Set objConn = Nothing



Message #4 by "Savonnya D. Rodrigues" <srod@f...> on Thu, 18 Jan 2001 16:14:12 -0600
Do you have to do an extra command text, type, and execute?



sdr

----- Original Message -----

From: "Håkan Frennesson" <hakan@c...>

To: "ASP Databases" <asp_databases@p...>

Sent: Thursday, January 18, 2001 10:52 AM

Subject: [asp_databases] RE: Multiple Insert into database





> Just a quick remark...you have the same name (strSQL) on the two

> strings..how does the script know which one to process?

>

> Hakan

>

> -----Original Message-----

> From: Savonnya D. Rodrigues [mailto:srod@f...]

> Sent: den 18 januari 2001 17:00

> To: ASP Databases

> Subject: [asp_databases] Multiple Insert into database

>

> I am trying to insert to tables into my database. I tested each one, one

by

> one, and their was no error. When I tried to run them at the same. It just

> ran one of them. Is their a way you can run them both together. I attached

> my code. Can you help me?

>

> 'Build the insert string

>

> strSQL = "Insert into Software (LicenseKeyNum, ProductID, " &

> "ServerApplication, InstalledBy, Manufacture, ProductName, Version,

> Description, Status, UserID, Comment) " & "Values('" &

> Request.Form("txtLicenseKeyNum") & "','" & Request.Form("txtProductID") &

> "','" & Request.Form("txtServerApplication") & "','" &

> Request.Form("txtInstalledBy") & "','" & Request.Form("txtManufacture") &

> "','" & Request.Form("txtProductName") & "','" &

Request.Form("txtVersion")

> & "','" & Request.Form("txtDescription") & "','" &

Request.Form("txtStatus")

> & "','" & Request.Form("txtUserID") & "','" & Request.Form("txtComment") &

> "')"

>

> strSQL = "Insert into PurchaseOrder (POComment,PCQuote , " &

"DateReceived,

> DateApproved,Cost, MaintenanceAgree, LicenseLocation) " & "Values('" &

> Request.Form("txtPOComment") & "','" & Request.Form("txtPCQuote") & "'," &

> Cdate(Request.Form("txtDateReceived")) & "," &

> Cdate(Request.Form("txtDateApproved")) & "," & Request.Form("txtCost") &

> ",'" & Request.Form("txtMaintenanceAgree") & "','" &

> Request.Form("txtLicenseLocation") & "')"

>

>

> 'Create and open the database object

>

> Set objConn = Server.CreateObject("ADODB.Connection")

>

> objConn.Open "DSN=ESS"

>

> 'Create the command object

>

> Set objCmd = Server.CreateObject("ADODB.Command")

>

> 'Set the command object properties

>

> Set objCmd.ActiveConnection = objConn

>

> objCmd.CommandText = strSQL

>

> objCmd.CommandType = adCmdText

>

> 'Execute the command

>

> objCmd.Execute

>

> 'Display the insert string

>

> Response.Write "The following insert string was executed and" & "the

values

> inserted into Software.<P>"

>

> Response.Write strSQL

>

> 'Close and dereference database objects

>

> Set objCmd = Nothing

>

> objConn.Close

>

> Set objConn = Nothing

>

Message #5 by "Ben Lew" <formula1@o...> on Thu, 18 Jan 2001 20:01:45 -0500
You need to name each strSQL a different name and execute each one with a

separate Execute statement, or have an execute Statement after each strSQL

string.



Ben





-----Original Message-----

From: Savonnya D. Rodrigues [mailto:srod@f...]

Sent: Thursday, January 18, 2001 11:00 AM

To: ASP Databases

Subject: [asp_databases] Multiple Insert into database





I am trying to insert to tables into my database. I tested each one, one by

one, and their was no error. When I tried to run them at the same. It just

ran one of them. Is their a way you can run them both together. I attached

my code. Can you help me?



'Build the insert string



strSQL = "Insert into Software (LicenseKeyNum, ProductID, " &

"ServerApplication, InstalledBy, Manufacture, ProductName, Version,

Description, Status, UserID, Comment) " & "Values('" &

Request.Form("txtLicenseKeyNum") & "','" & Request.Form("txtProductID") &

"','" & Request.Form("txtServerApplication") & "','" &

Request.Form("txtInstalledBy") & "','" & Request.Form("txtManufacture") &

"','" & Request.Form("txtProductName") & "','" & Request.Form("txtVersion")

& "','" & Request.Form("txtDescription") & "','" & Request.Form("txtStatus")

& "','" & Request.Form("txtUserID") & "','" & Request.Form("txtComment") &

"')"



strSQL = "Insert into PurchaseOrder (POComment,PCQuote , " & "DateReceived,

DateApproved,Cost, MaintenanceAgree, LicenseLocation) " & "Values('" &

Request.Form("txtPOComment") & "','" & Request.Form("txtPCQuote") & "'," &

Cdate(Request.Form("txtDateReceived")) & "," &

Cdate(Request.Form("txtDateApproved")) & "," & Request.Form("txtCost") &

",'" & Request.Form("txtMaintenanceAgree") & "','" &

Request.Form("txtLicenseLocation") & "')"





'Create and open the database object



Set objConn = Server.CreateObject("ADODB.Connection")



objConn.Open "DSN=ESS"



'Create the command object



Set objCmd = Server.CreateObject("ADODB.Command")



'Set the command object properties



Set objCmd.ActiveConnection = objConn



objCmd.CommandText = strSQL



objCmd.CommandType = adCmdText



'Execute the command



objCmd.Execute



'Display the insert string



Response.Write "The following insert string was executed and" & "the values

inserted into Software.<P>"



Response.Write strSQL



'Close and dereference database objects



Set objCmd = Nothing



objConn.Close



Set objConn = Nothing


  Return to Index