Inserting passed parameters into a SQL database

J

Justin Fields

Okay, this is driving me nuts. I'm sure it is something
small, but I can't figure out what it is.

I have a website up, with SQL database connected to it.
The database setup all seems to be fine. I can submit
forms to the database, run database queries on asp pages,
and all that. On one page, I have the database generate
hyperlinks with database fields as passed parameters. I
can click the link and go to a page that sees the
parameters, but I can't get it to insert the parameters
into a table. I've tried numerous ways.

The table that should be receiving the data has three
fields. Two are of type int and one is of type datetime.

The hyperlink seems to be formed correctly. It results in
something like this:

http://xxx.xxx.xxx.xxx/Marketing_Add_Contact_to_Next_Mailin
g.asp?addmid=1&contactindexer=1549

----------------------------------
SCENARIO 1

INSERT INTO MailingHistory
(mailingid, contactindexer, maildate)
VALUES (1, 1549, { fn NOW() })

As a database region in an asp page, on loading, that
works, and inserts the (static other than time) values
into the database.

----------------------------------
SCENARIO 2

SELECT
mailingdescriptions.mailingid,marketingcontacts.indexer,cur
rent_timestamp as curtime FROM
marketingcontacts,mailingdescriptions where
indexer=::contactindexer:: and
mailingdescriptions.mailingid=::addmid::

Also in a database region in an asp page, that also works,
returning the correct data from the database, using the
passed parameters "contactindexer" and "addmid".

----------------------------------
SCENARIO 3

INSERT INTO MailingHistory
(mailingid, contactindexer, maildate)
VALUES :):addmid::,::contactindexer::, { fn NOW() })

This does NOT work, and I have no idea why. I get the
yellow error box saying, "Database Results Error
The operation failed. If this continues, please contact
your server administrator."

----------------------------------
SCENARIO 4

Since the parameters worked in the where clause in
scenario 2 with a select statement, I rewrote the insert
insert to have the parameters in a select statement where
clause. The kludgy statement was:

INSERT INTO MailingHistory
(mailingid, contactindexer, maildate)
SELECT
mailingdescriptions.mailingid,marketingcontacts.indexer,cur
rent_timestamp as curtime FROM
marketingcontacts,mailingdescriptions where
indexer=::contactindexer:: and
mailingdescriptions.mailingid=::addmid::

Same error as scenario 3.

----------------------------------

What is going on here? It seems like this should have
taken about 5 minutes. My database is up and running. The
connection to the website is active, because I can query
and insert data. I can pass parameters. I just can't
insert passed parameters.

Help....

Thanks!

Justin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top