navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

Microsoft MVP

 

SQL INSERT INTO statement to add a record

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP and Database >> SQL INSERT INTO statement to add a record
Page: [1]
 
mylu

 

Posts: 128
Joined: 9/11/2006
Status: offline

 
SQL INSERT INTO statement to add a record - 3/31/2007 0:07:50   
I need to add a record to one table and update one column in a second table.

I have a form that post to ASP script. User inputs data to form. Clicks submit. Form post to ASP script to ADD a record to table one:

INSERT INTO tbl_tickets_data (ticket_number,resolution,error_code,updated_by) VALUES ('ticket_number','resolution','error_code','updated_by')

this will of course add the values ticket_number, resolution, error_code, updated_by to the columns of 'ticket_number','resolution','error_code','updated_by' in the table tbl_tickets_data.

What I need is for the VALUES in the form to be dynamic for what ever the user adds to those fields.

The SQL statement above is static and I can't figure out how to make the new record to the table dynamic to what ever the user inputs from the form.

Thanks.
Spooky

 

Posts: 26599
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: SQL INSERT INTO statement to add a record - 3/31/2007 4:30:34   
Can you just expand on "What I need is for the VALUES in the form to be dynamic for what ever the user adds to those fields. " ?

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to mylu)
mylu

 

Posts: 128
Joined: 9/11/2006
Status: offline

 
RE: SQL INSERT INTO statement to add a record - 3/31/2007 20:16:05   
Why yes I can!

With the SQL statement:

INSERT INTO tbl_tickets_data (ticket_number,resolution,error_code,updated_by) VALUES ('ticket_number','resolution','error_code','updated_by')

The Values added to the record are ticket_number, resolution, error_code , updated_by. Literally. When you click submit the words ticket_number, resolution, error_code , updated_by are added to the columns ticket_number, resolution, error_code , updated_by in the table tbl_tickets_data. (which is what the statement woould do as written)

ticket_number is a field on my form. The field is auto populated by passing the "actual" ticket number, say 28445, from the actual record 28445 in the tbl_tickets table to the form. From there I need to pass that ticket number to the SQL statement above. So the data added to the table tbl_tickets_data.ticket_number needs to be dynamic. The ticket_number is the key field in the relational database. IE table one contains the original ticket and table two contains additional notes to the ticket with ticket_number and the primary key.

Make sense?

(in reply to Spooky)
Spooky

 

Posts: 26599
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: SQL INSERT INTO statement to add a record - 3/31/2007 22:25:22   
Assuming thats part of an asp / SQL statement, you would need to do something like this?

sql = "INSERT INTO tbl_tickets_data (ticket_number,resolution,error_code,updated_by) VALUES ('"&request.form("ticket_number")&"','resolution','error_code','updated_by')"


Is that what you were meaning?
Thats the bare minimum for form submission, and you would be best to sanitize the input if used on the internet

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to mylu)
mylu

 

Posts: 128
Joined: 9/11/2006
Status: offline

 
RE: SQL INSERT INTO statement to add a record - 3/31/2007 22:34:57   
The SQL statement is the input on a DRW. I may be going about this the worng way I don't know.

"Thats the bare minimum for form submission, and you would be best to sanitize the input if used on the internet"

Can you explain this statement if you don't mind?

Thanks

(in reply to Spooky)
Spooky

 

Posts: 26599
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: SQL INSERT INTO statement to add a record - 4/1/2007 0:04:27   
For a DRW, this should be all you need (if entered as custom SQL in the wizard):

INSERT INTO tbl_tickets_data (ticket_number,resolution,error_code,updated_by) VALUES ('::ticket_number::','::resolution::','::error_code::','::updated_by::')

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to mylu)
mylu

 

Posts: 128
Joined: 9/11/2006
Status: offline

 
RE: SQL INSERT INTO statement to add a record - 4/1/2007 10:17:35   
I must be getting better at this because I tried that same code. All I get is an error "the custom query contains errors"When verify the query. And it doesn't pop up the error box describing the error.

The results are
Database Results Wizard Error
Unable to find operator in query string. Query string currently is INSERT INTO tbl_tickets_data (ticket_number,resolution,error_code,updated_by) VALUES ('::ticket_number::','::resolution::','::error_code::','::updated_by::')
One or more form fields were empty. You should provide default values for all form fields that are used in the query.

All fields do contain data..

(in reply to Spooky)
Spooky

 

Posts: 26599
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: SQL INSERT INTO statement to add a record - 4/1/2007 14:07:13   
As with ticket_number, are the other form fields named the same as the actual form text box?
Are there other columns in this database? Do they allow null or zero length inputs?

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to mylu)
mylu

 

Posts: 128
Joined: 9/11/2006
Status: offline

 
RE: SQL INSERT INTO statement to add a record - 4/1/2007 23:31:46   
Thanks for the conversation.. You pointed me in the correct direction:
Here's the statement that works.

fp_sQry="INSERT INTO tbl_tickets_data (ticket_number,resolution,error_code,updated_by,Timestamp,cpanel_name) VALUES ('"&request.form("ticket_number")&"','"&request.form("resolution")&"','"&request.form("error_code")&"','"&request.form("updated_by")&"','"&request.form("Timestamp")&"','"&request.form("cpanel_name")&"')"

Could you please explain your comment "you would be best to sanitize the input if used on the internet" ???

Thanks again..

(in reply to Spooky)
Spooky

 

Posts: 26599
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: SQL INSERT INTO statement to add a record - 4/2/2007 2:23:32   
An example :
http://www.frontpagewebmaster.com/m-352053/tm.htm

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to mylu)
mylu

 

Posts: 128
Joined: 9/11/2006
Status: offline

 
RE: SQL INSERT INTO statement to add a record - 4/2/2007 10:37:03   
Thanks! Since we're using FP DRW I guess I can assume we're OK.

(in reply to Spooky)
Page:   [1]

All Forums >> Web Development >> ASP and Database >> SQL INSERT INTO statement to add a record
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts