Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
Insert Statement Help, New Topic...
Old 06-06-2006, 06:25 AM Insert Statement Help, New Topic...
Skilled Talker

Posts: 79
Trades: 0
Can I say that this is the correct way to increase the value of a cell by 1, everytime the statement is exected?

<%
User = Replace( Trim("" & Request.QueryString("SupplierName")), "'", "''" )
%>
<%
set conn = Server.CreateObject("ADODB.Connection")
conn.Open MM_connSeek_STRING
SQL = "INSERT INTO tblSuppiers ([Hits]) " _ & " VALUES('" & 1 & "')"
conn.Execute SQL
%>
malhyp is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-06-2006, 06:27 AM Re: Insert Statement Help, New Topic...
Skilled Talker

Posts: 79
Trades: 0
Hmm, Id say its not. Just got this...

Microsoft JET Database Engineerror '80040e37'

Could not find output table 'tblSuppiers'. /html/product.asp, line 76

Last edited by malhyp; 06-06-2006 at 06:29 AM..
malhyp is offline
Reply With Quote
View Public Profile
 
Old 06-06-2006, 06:30 AM Re: Insert Statement Help, New Topic...
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Code:
UPDATE table SET column = column + 1 WHERE criteria
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 06-06-2006, 07:26 AM Re: Insert Statement Help, New Topic...
Skilled Talker

Posts: 79
Trades: 0
The WHERE clause im not 100% sure about.

I did this...

UPDATE tblSuppliers
SET Hits = Hits + 1
WHERE SupplierName = SupplierName

Which updates all the suppliers by 1.

"UPDATE tblSuppliers SET Hits = Hits + 1 WHERE ?

The page transfers from one page to the next a URL Parameter "SupplierName".

Not 100% sure on what I should have there...
malhyp is offline
Reply With Quote
View Public Profile
 
Old 06-06-2006, 08:00 AM Re: Insert Statement Help, New Topic...
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
the criteria should isolate the one row to update

so SupplierName = request.querystring("SupplierName")

although you should do some checks rather than use the querystring directly
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 06-06-2006, 08:38 AM Re: Insert Statement Help, New Topic...
Skilled Talker

Posts: 79
Trades: 0
UPDATE tblSuppliers
SET Hits = Hits + 1
WHERE SupplierName = request.querystring("SupplierName")

This look oky?

Last edited by malhyp; 06-06-2006 at 08:43 AM..
malhyp is offline
Reply With Quote
View Public Profile
 
Old 06-06-2006, 08:40 AM Re: Insert Statement Help, New Topic...
Skilled Talker

Posts: 79
Trades: 0
givin me this...




Microsoft VBScript compilation error '800a0401'
Expected end of statement
/html/productDescription.asp, line 67 Command1.CommandText = "UPDATE tblSuppliers SET Hits = Hits + 1 WHERE SupplierName = request.querystring("SupplierName")"---------------------------------------------------------------------------------------------------------------------------^

Last edited by malhyp; 06-06-2006 at 08:43 AM..
malhyp is offline
Reply With Quote
View Public Profile
 
Old 06-06-2006, 08:55 AM Re: Insert Statement Help, New Topic...
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
you should add in the contatenation
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 06-06-2006, 09:34 AM Re: Insert Statement Help, New Topic...
Skilled Talker

Posts: 79
Trades: 0
Sorry Chris, what is a contatenation?
malhyp is offline
Reply With Quote
View Public Profile
 
Old 06-06-2006, 09:46 AM Re: Insert Statement Help, New Topic...
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
might have helped if I'd have typed it correctly

concatenation

WHERE SupplierName = " & request.querystring("SupplierName")

I don't always type the exact code, sometimes you have to think. It's all part of the learning process.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 06-06-2006, 10:36 AM Re: Insert Statement Help, New Topic...
Skilled Talker

Posts: 79
Trades: 0
Thanks Chris, it worked. I originally had it all included in the code that Dreamweaver creates. As soon as I got rid of all the extras, it worked.

Thanks Heaps.

Also just had a look at your pic. The reseblance is amaizing. Lolz.

Cheers.

Mally.

Last edited by malhyp; 06-06-2006 at 10:54 AM..
malhyp is offline
Reply With Quote
View Public Profile
 
Old 06-06-2006, 12:29 PM Re: Insert Statement Help, New Topic...
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,938
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Trades: 0
malhyp: having seen a few of your posts, I think I can give you a piece of advice that will save you a bunch of time.

Don't use DW-created (or for that matter, any other WYSIWYG-generated) code. It's not optimized and can quite often be very buggy, as you're learning. The best thing you can do is to get a colour-coded text editor (Notepad++ for example) that will allow you to hand-code your ASP and still see the different aspects of string concatenation, SQL Query manipulation, etc.

Also, when you get an error code such as 800a0401 , you can often Google it and find your answer that way.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
(my blog)


Please login or register to view this content. Registration is FREE
(with proof)
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 06-06-2006, 07:07 PM Re: Insert Statement Help, New Topic...
Skilled Talker

Posts: 79
Trades: 0
Yeh, thanks for that. I think I learnt that the hard way. It is Dreamwever that confuses me.
malhyp is offline
Reply With Quote
View Public Profile
 
Old 06-06-2006, 07:08 PM Re: Insert Statement Help, New Topic...
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,938
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Trades: 0
Good. Now that you've learned it, get your *** to steppin' and finding a good text editor.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
(my blog)


Please login or register to view this content. Registration is FREE
(with proof)
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 06-07-2006, 01:50 AM Re: Insert Statement Help, New Topic...
Skilled Talker

Posts: 79
Trades: 0
I dont quite understand this.

I have 3 pages.

1) search.asp which is set to POST to the
2) results.asp page. From there if you want to view more detils on a particular subject in the results page, you click on the DETAIL link which is set as a Go To Detail Page function. This directs you to the.
3) productdetail.asp page, which shows all the suppliers details.

When I insert the code below in the 3) productdetail.asp page, it updates the database by 1 each time the result is viewed.

If I insert the code in the 2) results.asp page, it dose nothing?

<%
set conn = Server.CreateObject("ADODB.Connection")
conn.Open MM_connSeek_STRING
SQL = "UPDATE tblSuppliers SET Hits=Hits+1 WHERE SupplierName='" & Replace(Request.QueryString("SupplierName"), "'", "''") & "'"
conn.Execute SQL
%>

To confirm:

search.asp has a form with text fields, set to POST. When submitted this goes to the results.asp page.

results.asp has the following SQL which pulls all the details together.

SELECT SupplierName, Location, ShortDescription, TimberSpecies, CategoryTitle, Country, CustomerType
FROM Query1
WHERE TimberSpecies LIKE '%MMColParam%' AND CategoryTitle LIKE '%MMColParam2%' AND Location LIKE '%MMColParam3%' AND CustomerType = 'Trade/Retail'
ORDER BY CategoryTitle, TimberSpecies ASC

In the same page it has a Go To Detail Link which looks something like this...

<a href="productdetail.asp?<%= MM_keepNone & MM_joinChar(MM_keepNone) & "SupplierName=" & rsSearchResult.Fields.Item("SupplierName").Value %>">More Details</a>

Any ideas on where I have gone wrong?

Mally
malhyp is offline
Reply With Quote
View Public Profile
 
Old 06-07-2006, 02:25 AM Re: Insert Statement Help, New Topic...
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
does Query1 have columns with data such as

MMColParam, MMColParam2, or MMColParam3 ?????

also when you use AND on each criteria they ALL have to equate to true.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 06-07-2006, 02:50 AM Re: Insert Statement Help, New Topic...
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,938
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Trades: 0
malhyp: the code in question can only work in case 3. The point of that code is to let you know the number of times a supplier has been viewed.

Now...what happens is this.

The Go To Detail Link contains a querystring key/value pair (in this case SupplierName = the name corresponding to the record from your database). Anything you see in a URL of the form ?something=value or &somethingelse=anothervalue is a querystring key/value pair.

So...from this, we know that the SupplierName key/value pair is passed via that hyperlink (when you click on it) to the productdetail.asp page. This is where that code should go, since it updates the query based on...you guessed it, the SupplierName querystring key/value pair.

It also is probably retrieving the supplier info based on the supplier details.

Mind you, this isn't the best way to go about doing it. Longer supplier names and supplier names with spaces can cause issues, as well as suppliers with the same name but duplicate addresses (warehouses, for example).

What I always use for these situations is an AutoNumber field (I'm assuming you use Access). AutoNumber fields are fields that are created specifically as incremental counters for a series of database records. Each AutoNumber value is generated by the system, cannot be edited (to avoid any screwups) and will be used once and only once.

So...for example, if I have 3 records in a database, I might have something like this (sorry about the weird formatting...apparently I can't do a table within the board):

AutoNumber Field Other fields in table

1 Other Fields for Record 1
2 Other Fields for Record 2
3 Other Fields for Record 3

Now, let's say I deleted the second record and added a fourth. My new table would look something like this:

AutoNumber Field Other fields in table

1 Other Fields for Record 1
3 Other Fields for Record 3
4 Other Fields for Record 4


As you can see, it did not reuse the 2 value, because it was already used once (even though it was deleted).

Why is this significant?

Because if you use something to the extent of "autonumber=" & RS ("AutoNumberField") as part of your querystring, you will be guaranteed to get no more than one possible record for each hyperlink clicked on.

Hope that makes some sense. If not, mess with it. (BACK UP WHAT YOU'RE DOING FIRST. VERY KEY.)
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
(my blog)


Please login or register to view this content. Registration is FREE
(with proof)

Last edited by ADAM Web Design; 06-07-2006 at 02:55 AM..
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 06-07-2006, 03:03 AM Re: Insert Statement Help, New Topic...
Skilled Talker

Posts: 79
Trades: 0
Query1 dose have....

<%
Dim rsSearchResult__MMColParam
rsSearchResult__MMColParam = "1"
If (Request("Keyword") <> "") Then
rsSearchResult__MMColParam = Request("Keyword")
End If
%>
<%
Dim rsSearchResult__MMColParam2
rsSearchResult__MMColParam2 = "2"
If (Request("CategoryTable") <> "") Then
rsSearchResult__MMColParam2 = Request("CategoryTable")
End If
%>
<%
Dim rsSearchResult__MMColParam3
rsSearchResult__MMColParam3 = "3"
If (Request("Location") <> "") Then
rsSearchResult__MMColParam3 = Request("Location")
End If
%>
malhyp is offline
Reply With Quote
View Public Profile
 
Old 06-07-2006, 03:20 AM Re: Insert Statement Help, New Topic...
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
WHERE TimberSpecies LIKE '%MMColParam%' AND CategoryTitle LIKE '%MMColParam2%' AND Location LIKE '%MMColParam3%' AND CustomerType = 'Trade/Retail'
Mally, since when has "MMColParam" been a timber species ??


if your table has values such as "MMColParam" in it you have got something badly wrong somewhere.

HINT: Look back to post #10

As Adam posted, A lot of these issues can be attributed back to use of DW generated gibberish. It is not helping you understand how to build queries from form input.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 06-07-2006, 03:49 AM Re: Insert Statement Help, New Topic...
Skilled Talker

Posts: 79
Trades: 0
yeh, I know. The site is riddled with DW statements. Anything that I create new is being written manualy. But the rest is all Dutch to me.

Anyhows back to post # 10.

Mally.
malhyp is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Insert Statement Help, New Topic...
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 2.08877 seconds with 12 queries