|
| |
|
|
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.
|
|
|
|
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?
|
|
|
|
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
|
|
|
|
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..
|
|
|
|
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..
|
|
|
|
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.
|
|
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
|
|
|