Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Array for loop to an Insert

Author  Topic 

sanj
Starting Member

22 Posts

Posted - 2009-06-01 : 14:42:20
Hi,

I hope someone can help, I need an example of an insert from an ajax response, I have an output as:


{"forename":["Forname1","forname2"],"surname":["Surname2","surname2"],"dateOfBirth":["04\/07\/1970","05
\/27\/2009"]}


and need to insert into a db


varforename = Forname1
varsurname = Surname1
vardateOfBirth = 04/07/1970


Set command1 = Server.CreateObject ("ADODB.Command")
command1.ActiveConnection = MM_assetreg_STRING
command1.CommandText = "INSERT INTO upload_tbl (forename, surname, dateOfBirth) VALUES (?, ?, ? ) "
command1.Parameters.Append command1.CreateParameter("var1", 200, 1, 255, varforename)
command1.Parameters.Append command1.CreateParameter("var2", 200, 1, 255, varsurname)
command1.Parameters.Append command1.CreateParameter("var3", 200, 1, 255, vardateOfBirth)
command1.CommandType = 1
command1.CommandTimeout = 0
command1.Prepared = true
command1.Execute()


How can I loop the insert command?

Thanks

snSQL
Master Smack Fu Yak Hacker

1837 Posts

Posted - 2009-06-01 : 20:19:06
The loop needs to be in your client code, so this is a scripting or .NET question.
Go to Top of Page
   

- Advertisement -