Code Bank
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingCode Bank

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old June 22nd, 2004, 10:40 AM
obriend6 obriend6 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 6 obriend6 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Small sql database query problem

i am new to asp and have been going grand till i hit this little snag.
I am attempting to query the database to return the entry in the database with Manufacture_Name
equals to a value passed into this page by a form in the previous page. This wont work for me.
However it will work for me when i pass in the vlue of the Manufacture_Code of the same entry in the database. i am only making a small error betwwen the different syntax of numbers and letters.
Any help would be very appreciated. here is my code


'Dimension variables
Dim WordID 'Array to hold the ID number for each comment to be deleted
'Set the Lock Type for the records so that the record set is only locked when it is deleted
rsCommon.LockType = 3

'Run through till all checked bad words are deleted
iaryBadWordID = Request.Form("m_code")

'Initalise the strSQL variable with an SQL statement to query the database

'strSQL = "SELECT " & strDbTable & "Manufacture.* FROM " & strDbTable & "Manufacture ORDER BY " & strDbTable & "Manufacture.Manufacture_Code ASC;"
strSQL = "SELECT " & strDbTable & "Manufacture.* FROM " & strDbTable & "Manufacture"
strSQL = strSQL & " WHERE Manufacture_Name =" & ('iaryBadWordID')

'Query the database
rsCommon.Open strSQL, adoCon



But it does work when i change the value passed in from the previous form, to be the Manufacture_Code


That code is identical only for this line

strSQL = "SELECT " & strDbTable & "Manufacture.* FROM " & strDbTable & "Manufacture"
strSQL = strSQL & " WHERE Manufacture_Code =" & ('iaryBadWordID')

So i'm guessing its on this line i have the problem.

Reply With Quote
  #2  
Old June 22nd, 2004, 10:41 AM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
ASP Free God 14th Plane (11500 - 11999 posts)
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,770 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 6 h 58 m 22 sec
Reputation Power: 452
Do a Response.write on your sql statement do see what is being passed to the database.

Reply With Quote
  #3  
Old June 22nd, 2004, 10:53 AM
obriend6 obriend6 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 6 obriend6 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
the database isn't being connected to. As in, the SELECT .... FROM.... WHERE statementis leaving me with nothing for Manufacture_Name. The statement isn't executing due to an error. Perhaps the line

strSQL = "SELECT " & strDbTable & "Manufacture.* FROM " & strDbTable & "Manufacture"
strSQL = strSQL & " WHERE Manufacture_Name =" & ('iaryBadWordID')

should be something like

strSQL = "SELECT " & strDbTable & "Manufacture.* FROM " & strDbTable & "Manufacture"
strSQL = strSQL & " WHERE Manufacture_Name =" "'" & ('iaryBadWordID') "'"

seeing as i'm dealing with text. and not numbers

Reply With Quote
  #4  
Old June 22nd, 2004, 10:55 AM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
ASP Free God 14th Plane (11500 - 11999 posts)
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,770 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 6 h 58 m 22 sec
Reputation Power: 452
Like I said, do a response.write on the sql statement and post what it displays in the browser.

Reply With Quote
  #5  
Old June 22nd, 2004, 10:58 AM
obriend6 obriend6 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 6 obriend6 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
could you write out how the statement would look. i'm new to this. thanks for your help

Reply With Quote
  #6  
Old June 22nd, 2004, 11:03 AM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
ASP Free God 14th Plane (11500 - 11999 posts)
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,770 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 6 h 58 m 22 sec
Reputation Power: 452
Code:
strSQL = "SELECT " & strDbTable & "Manufacture.* FROM " & strDbTable & "Manufacture"
strSQL = strSQL & " WHERE Manufacture_Name =" & ('iaryBadWordID') 

Response.write(strSQL)
Response.end

Reply With Quote
  #7  
Old June 22nd, 2004, 11:20 AM
obriend6 obriend6 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 6 obriend6 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
This is what i got:

SELECT tblGBManufacture.* FROM tblGBManufacture WHERE Manufacture_Name =Acme

Acme is correct. These are the current entries in my Manufacture Database

Manufacture CodeManufacture NameContact NameAddress 1Address 2CityCountyPost CodeCountryPhone NumberFax NumberE-mail AddressWeb AddressModified By852 ihgjk uju uuygu uyv u vu vu v 123 125 vgo uiy 8526 tool frank main town main street cligo sligo p4k4 irl 45674 87 ppjpij pijopijoi 963 Acme John dub dub dub dyg


(the bit missing was just my copying and pasting)


What i am trying to do with this code is pass in the manufacture name but store the manufactures code.
As i said earlier i can pass in the manufacturer code and save its name. this is my more complete code.


<% Option Explicit %>
<!--#include file="common.asp" -->

<%
'Set the response buffer to true as we maybe redirecting
Response.Buffer = True

'Dimension variables
Dim iaryBadWordID 'Array to hold the ID number for each comment to be deleted

'Set the Lock Type for the records so that the record set is only locked when it is deleted
rsCommon.LockType = 3

'Run through till all checked bad words are deleted
iaryBadWordID = Request.Form("Manufacture_Code")

'Initalise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT " & strDbTable & "Manufacture.* FROM " & strDbTable & "Manufacture"
strSQL = strSQL & " WHERE Manufacture_Name =" & (iaryBadWordID)

Response.write(strSQL)
Response.end

'Query the database
rsCommon.Open strSQL, adoCon

Dim mcode
mcode = rsCommon("Manufacture_Code") <------ this is were i am trying to obtain the
manufacture_code i want to save. i save it
below


'Reset Server Variables
rsCommon.Close
'Set rsCommon = Nothing
'adoCon.Close
'Set adoCon = Nothing
%>





<%

'Set the response buffer to true as we maybe redirecting
Response.Buffer = True

'Dimension variables
Dim intBadWord 'Loop counter for the bad words


'Set the Lock Type for the records so that the record set is only locked when it is deleted
rsCommon.LockType = 3

'Initalise the strSQL variable with the SQL string
strSQL = "SELECT " & strDbTable & "Component.* FROM " & strDbTable & "Component;"

'Query the database
rsCommon.Open strSQL, adoCon


'Tell the recordset we are adding a new record
rsCommon.AddNew

'Add new records to fields
rsCommon.Fields("Component_Code") = Request.Form("Component_Code")
rsCommon.Fields("Name") = Request.Form("Name")
rsCommon.Fields("Location") = Request.Form("Location")
rsCommon.Fields("Manufacture_Code") = mcode
'rsCommon.Fields("Modify_By") = Request.Form("Component_Code")
rsCommon.Fields("Modify_By") = application("modify")


'save the recordset back to the database
rsCommon.Update


'Reset Server Variables
rsCommon.Close
Set rsCommon = Nothing
adoCon.Close
Set adoCon = Nothing

'Return to the bad word admin page

Response.Redirect "components.asp"
%>

Reply With Quote
  #8  
Old June 22nd, 2004, 11:55 AM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
ASP Free God 14th Plane (11500 - 11999 posts)
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,770 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 6 h 58 m 22 sec
Reputation Power: 452
should be like this
Code:
...WHERE Manufacture_Name = '" & iaryBadWordID  & "'"

Reply With Quote
  #9  
Old June 23rd, 2004, 03:39 AM
obriend6 obriend6 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 6 obriend6 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I'm just after seeing your last post. Thanks very much for your help. That worked perfectly

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingCode Bank > Small sql database query problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT