Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > Adobe Web Programming > Dreamweaver (all versions)
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Dreamweaver (all versions) section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 1st, 2006, 11:52 PM
Authorized User
 
Join Date: Aug 2005
Location: , , .
Posts: 96
Thanks: 0
Thanked 0 Times in 0 Posts
Default Is it possible to combine two forms into one?

How do I create an update form, in a search.asp page.
I have a search.asp page which when submitted transfers to the results.asp page. In the search I would like to also create an insert statement. The search.asp page has the following.

Form: searchForm (Post)
Text Field: KeywordSearch
List Menu: CategoryTable
List Menu: Location
Button: Search

When a client enters data in the search.asp page, I would like for the data, to be submitted to a database at the same time it searches the database. This using an insert statement. The reason for this is so that we can see what everyone is searching for.

The database/table we created has the following.

Table: tblSearches
Field: idSearch (Auto Number)
Field: location (Text)
Field: category (Text)
Field: user (Text)
Field: keyWord (Text)

At the moment I cant create an insert form because of the form that already exists in the search.asp page.

Can anyone suggest what to do.

Ideally it would be good to be able to combine two forms into one, but I am told that this is not possible.

TA

Mally.
Reply With Quote
  #2 (permalink)  
Old June 2nd, 2006, 05:55 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Right, so you want to do this with a Dreamweaver behavior?

I think it's much easier to fire your own insert statement, and drop the behavior (for inserting that is; for searching you can still use the existing behavior).

Just look at the code that Dreamweaver generates and copy the relevant parts of the connection code. Then build up a SQL statement using something like Request.Form("KeywordSearch") and other fields, and manually send the SQL statement to the database by using the connection's Execute method.

For more details: http://msdn.microsoft.com/library/de...cnnexecute.asp

HtH,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Reply With Quote
  #3 (permalink)  
Old June 2nd, 2006, 06:17 PM
Authorized User
 
Join Date: Aug 2005
Location: , , .
Posts: 96
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Imar, I want to confirm that I do this all in the results.asp page and not the seasrech.asp page.

Thanks for your reply.

Mally.

Reply With Quote
  #4 (permalink)  
Old June 3rd, 2006, 02:27 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Is that a question or a statement? If it's a question: yes that would work fine. The search page submits all the details to the results page which then inserts the search term in the database and displays the results.

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Reply With Quote
  #5 (permalink)  
Old June 3rd, 2006, 02:43 AM
Authorized User
 
Join Date: Aug 2005
Location: , , .
Posts: 96
Thanks: 0
Thanked 0 Times in 0 Posts
Default

That was the questions. Thanks again Imar.

Mally.


Reply With Quote
  #6 (permalink)  
Old June 3rd, 2006, 10:57 PM
Authorized User
 
Join Date: Aug 2005
Location: , , .
Posts: 96
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Can you see something wrong with this insert statement?

<%
        if(Request.Form("Keyword") <> "") then Command1__MMColParam = Request.Form("Keyword")

        if(Request.Form("CategoryTable") <> "") then Command1__MMColParam2 = Request.Form("CategoryTable")

        if(Request.Form("Location") <> "") then Command1__MMColParam3 = Request.Form("Location")

        if(Session("MM_UserName") <> "") then Command1__MMColParam4 = Session("MM_UserName")
%>

        <%
        set Command1 = Server.CreateObject("ADODB.Command")
        Command1.ActiveConnection = MM_connSeek_STRING
        Command1.CommandText = "INSERT INTO tblSearchResults (result, category, location, user) VALUES (( Keyword, CategoryTable, Location, MM_UserName) WHERE result = '%" + Replace(Command1__MMColParam, "'", "''") + "%' AND category = '%" + Replace(Command1__MMColParam2, "'", "''") + "%' AND location = '%" + Replace(Command1__MMColParam3, "'", "''") + "%' AND user = '%" + Replace(Command1__MMColParam4, "'", "''") + "%') "
        Command1.CommandType = 1
        Command1.CommandTimeout = 0
        Command1.Prepared = true
        Command1.Execute() <--- Line 48
        %>

Component details are...

search.asp page
Form: searchForm (POST)
Text Field: Keyword
Text Field: CategoryTable
Text Field: Location
Session: MM_Username

database properties
Table: tblSearchResults
Number: idSearch (AutoNumber)
Text: result (Which will be inserted by the "Keyword" text field)
Text: category (Which will be inserted by the "CategoryTable" text field)
Text: location (Which will be inserted by the "Location" text field)
Text: user (Which will be inserted by the Session "MM_Username")

Keeps giving me this...

INSERT INTO tblSearchResults (result, category, location, user) VALUES (( Keyword, CategoryTable, Location, MM_UserName) WHERE result = '%spotted gum%' AND category = '%%%' AND location = '%%%' AND user = '%malhyp%')

Microsoft JET Database Engine error '80040e14'
Syntax error in INSERT INTO statement.
/html/results.asp, line 48


Reply With Quote
  #7 (permalink)  
Old June 4th, 2006, 05:20 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi there,

If I were you, I'd base your custom INSERT statement on another INSERT statement that Dreamweaver has generated, and not on an SELECT statement. That way, you can see how the syntax for INSERT works and it'll be easier to modify it to make it a valid statement.

Right now, you list column names while you should be listing the values in the VALUES section and you have a WHERE clause that doesn't make sense.

Hope this helps,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Reply With Quote
  #8 (permalink)  
Old June 4th, 2006, 07:30 AM
Authorized User
 
Join Date: Aug 2005
Location: , , .
Posts: 96
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok, so id say that something like this would be better.

<%
set conn = Server.CreateObject("ADODB.Connection")
conn.Open MM_connSeek_STRING
SQL = "INSERT INTO tblSearchResults (result, category, location, user) " _
& " VALUES('" & Keyword & "', '" & CategoryTable & "', '" & Location & "', '" & MM_UserName & "')"
conn.Execute SQL
%>

But the values I have are the text field and drop down names from the page that sends the information being the search.asp page. Is this correct? The username I have as the session variable...

Mally

Adding this to the code, Response.Write "DEBUG SQL: " & SQL & "".

Gives me a result of this.

DEBUG SQL: INSERT INTO tblSearchResults (result, category, location, user) VALUES('', '', '', '')
--------------------------------------------------------------------------------

Microsoft JET Database Engine error '80040e14'
Syntax error in INSERT INTO statement.
/html/results.asp, line 34
Reply With Quote
  #9 (permalink)  
Old June 4th, 2006, 01:02 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

So, the values are empty. Before you execute the SQL statement, make sure that the variables Keyword and CategoryTable etc have a valid value...

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Reply With Quote
  #10 (permalink)  
Old June 5th, 2006, 06:41 AM
Authorized User
 
Join Date: Aug 2005
Location: , , .
Posts: 96
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hmmm, I changed the code to read this... Less the MM_UserName.

<%
set conn = Server.CreateObject("ADODB.Connection")
conn.Open MM_connSeek_STRING
SQL = "INSERT INTO tblSearchResults (result, category, location) " _
& " VALUES('" & Keyword & "', '" & CategoryTable & "', '" & Location & "', ')"
conn.Execute SQL
%>

And there was no error message. What it did do was enter a new blank line in the database. So I did 4 searches on the database and it entered 4 blank lines with no values....

?



Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Combine two queries snufse SQL Server 2005 6 June 24th, 2008 09:42 PM
combine the nodes pravind XSLT 3 April 23rd, 2007 01:11 PM
How to combine two value-of selects? myhtpc XSLT 2 February 14th, 2006 06:20 AM
Best Way To Combine Reports ? jkirst BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 0 May 16th, 2005 09:56 AM
combine 2 queries collie SQL Server 2000 2 November 29th, 2004 03:09 PM



All times are GMT -4. The time now is 11:54 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.