ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 30th, 2009, 04:53 PM
sanj sanj is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 130 sanj User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 h 52 m 55 sec
Reputation Power: 7
Ajax reponse to Insert

Hi,

Does anyone have an example of an insert from an ajax response, I have an output as

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


and need to insert into a db

PHP Code:
 INSERT INTO dbo.login_tbl (forenamesurnamedateOfBirthVALUES (value1value2value3


Thanks

Reply With Quote
  #2  
Old May 30th, 2009, 06:41 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 15th Plane (12000 - 12499 posts)
 
Join Date: Jun 2003
Posts: 12,211 Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 3 Days 3 h 32 m 41 sec
Reputation Power: 1969
Try a complete explanation. Your question doesn't make sense to me.

In general, if you wanted to do an ajax transaction to a db on the server you'd:
- Gather up whatever data you want to insert in the db
- Create an xmlhttp object in the browser
- Use the xmlhttp object to post the data to a receiving asp page on the web server (oh yeah, you've gotta write that page too)
- Have the asp page extract and format what you want to insert, have it connect to the db and perform the insert.
__________________
======
Doug G
======
I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain

Reply With Quote
  #3  
Old May 31st, 2009, 08:02 AM
sanj sanj is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 130 sanj User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 h 52 m 55 sec
Reputation Power: 7
Doug,

Thanks for your reply,

I know how to insert a single record into a db:
i.e. if it was just one:

PHP Code:
{"forename":["Forname1"],"surname":["Surname1"],"dateOfBirth":["04\/07\/1970"]}  

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"2001255varforename)
command1.Parameters.Append command1.CreateParameter("var2"2001255varsurname)
command1.Parameters.Append command1.CreateParameter("var3"2001255vardateOfBirth)
command1.CommandType 1
command1
.CommandTimeout 0
command1
.Prepared true
command1
.Execute() 


but do not know how to do this for an array
PHP Code:
{"forename":["Forname1","forname2"],"surname":["Surname2","surname2"],"dateOfBirth":["04\/07\/1970","05 
\/27\/2009"
]}  

INSERT INTO dbo.login_tbl (forenamesurnamedateOfBirthVALUES (value1value2value3


Any help please.

Reply With Quote
  #4  
Old May 31st, 2009, 09:27 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 15th Plane (12000 - 12499 posts)
 
Join Date: Jun 2003
Posts: 12,211 Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 3 Days 3 h 32 m 41 sec
Reputation Power: 1969
One way is to loop through the array and do a single insert for each record, which is probably the way I'd do it. Beyond that your questions is pretty much a sql question it seems.

Reply With Quote
  #5  
Old June 3rd, 2009, 05:44 PM
sanj sanj is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 130 sanj User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 h 52 m 55 sec
Reputation Power: 7
Thanks Doug,

I will create the loop.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > Ajax reponse to Insert


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
Stay green...Green IT