Re: CFQuery to Database
if its just a few records then use query of query to get your subset of results and then insert the results into database B if this is a regular occurrence and happens often then then you may want to look at creating a DTS script on your SQL server and scheduling that to do the job. On Sat, Mar 10, 2012 at 10:32 PM, IT (Pradeep Viswanathan) prade...@emiratesnbd.com wrote: I have couple of records which are filtered from data source x which is oracle based and require to insert it into datasource y which is MS SQL server. The number of rows, columns is not fixed, however I have the records in a Query object, what would be the best way to insert get this data into the other database? Thanks in advance. DISCLAIMER: This e-mail message including any of its attachments is intended solely for the addressee(s) and may contain privileged information. If you are not the addressee or you have received this email message in error, please notify the sender who will remove your details from its database. You are not authorized to read, copy, disseminate, distribute or use this e-mail message or any attachment to it in any manner and must delete the email and destroy any hard copies of it. This e-mail message does not contain financial instructions or commitments of any kind. Any views expressed in this message are those of the individual sender and do not necessarily reflect the views of Emirates NBD PJSC, or any other related subsidiaries, entities or persons. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:350349 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
RE: CFQuery to Database
Thanks Russ, Scott@fussionapps has been kind enough to give me a nice code.. The little challenge was that the columns were not fixed and query results are completely dyanmic... Just posting it here for reference CFLOOP query=qry_data CFQUERY name=qry_insert datasource=#request.dsn# INSERT INTO SomeTable ( CFLOOP from=1 to=#Listlen(qry_data.ColumnList)# index=i #qry_data.GetMetaData().GetColumnName(i)# CFIF !i EQ ListLen(qry_data.ColumnList), /CFIF /CFLOOP) VALUES ( CFLOOP from=1 to=#Listlen(qry_data.ColumnList)# index=i !--- Putting these into variables to make it easier for you to reuse later if needed --- CFSET variables.ColumnName = qry_data.GetMetaData().GetColumnName(i) CFSET variables.ColumnType = qry_data.GetMetaData().GetColumnTypeName(i) CFSET variables.ColumnData = qry_data[qry_data.GetMetaData().GetColumnName(i)][qry_data.currentrow] !--- Check Len so we can insert NULLs where needed --- CFIF Len(variables.ColumnData) #variables.ColumnType# CFSWITCH expression=#variables.ColumnType# !--- Things that need to be wrapped in single quotes(add as needed) --- CFCASE value=VARCHAR,NVARCHAR,DATETIME,SMALLDATETIME,UNIQUEIDENTIFIER '#variables.ColumnData#' /CFCASE !--- You can add other cases here if you want --- !--- Things that dont --- CFDEFAULTCASE #variables.ColumnData# /CFDEFAULTCASE /CFSWITCH CFELSE NULL /CFIF CFIF !i EQ ListLen(qry_data.ColumnList), /CFIF /CFLOOP) /CFQUERY /CFLOOP /CFOUTPUT Note: small corrections may be required to the code. -Original Message- From: Russ Michaels [mailto:r...@michaels.me.uk] Sent: Sunday, March 11, 2012 1:48 PM To: cf-talk Subject: Re: CFQuery to Database if its just a few records then use query of query to get your subset of results and then insert the results into database B if this is a regular occurrence and happens often then then you may want to look at creating a DTS script on your SQL server and scheduling that to do the job. On Sat, Mar 10, 2012 at 10:32 PM, IT (Pradeep Viswanathan) prade...@emiratesnbd.com wrote: I have couple of records which are filtered from data source x which is oracle based and require to insert it into datasource y which is MS SQL server. The number of rows, columns is not fixed, however I have the records in a Query object, what would be the best way to insert get this data into the other database? Thanks in advance. DISCLAIMER: This e-mail message including any of its attachments is intended solely for the addressee(s) and may contain privileged information. If you are not the addressee or you have received this email message in error, please notify the sender who will remove your details from its database. You are not authorized to read, copy, disseminate, distribute or use this e-mail message or any attachment to it in any manner and must delete the email and destroy any hard copies of it. This e-mail message does not contain financial instructions or commitments of any kind. Any views expressed in this message are those of the individual sender and do not necessarily reflect the views of Emirates NBD PJSC, or any other related subsidiaries, entities or persons. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:350350 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
CFQuery to Database
I have couple of records which are filtered from data source x which is oracle based and require to insert it into datasource y which is MS SQL server. The number of rows, columns is not fixed, however I have the records in a Query object, what would be the best way to insert get this data into the other database? Thanks in advance. DISCLAIMER: This e-mail message including any of its attachments is intended solely for the addressee(s) and may contain privileged information. If you are not the addressee or you have received this email message in error, please notify the sender who will remove your details from its database. You are not authorized to read, copy, disseminate, distribute or use this e-mail message or any attachment to it in any manner and must delete the email and destroy any hard copies of it. This e-mail message does not contain financial instructions or commitments of any kind. Any views expressed in this message are those of the individual sender and do not necessarily reflect the views of Emirates NBD PJSC, or any other related subsidiaries, entities or persons. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:350341 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Fw: CFQuery of database tables
Winston, I think queryName.ColumnList will help you out (where 'queryName' is the name of your query). It contains a comma-delimited list of all the column names returned by the query. To do what you want you'll need an outer loop over your query results, and then an inner loop that goes over each item in the queryName.ColumnList and displays it's value (you'll need to use Evaluate() for this last part). If you could, please post messages in plain text format, they're easier to read that way and take up less bandwidth. Thanks. Hope that helps, -Max ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: CFQuery of database tables
You could loop round the commma delimted list of column names given by query_name.ColumnList. -Original Message- From: Winston Sia [mailto:[EMAIL PROTECTED]] Sent: 28 February 2001 08:16 To: CF-Talk Cc: [EMAIL PROTECTED] Subject: Fw: CFQuery of database tables This is a multi-part message in MIME format. --=_NextPart_000_020E_01C0A1A1.B3261D40 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi, I'm would like to make a query to each database table, with a "select *" = to output all records. I am going to use CFTABLE to output the results. = Is there any way I can do this wihtout having to specify one by one the = column/field names of that table? I am trying to do this since I want to display or output the whole = contents of all the tables in my database, which I am going to transfer = to Excel sheet. You see, the data I want to get is on IBM DB2, which I want to export to = my local SQL database. And the DB2 is remote, and I have no access to = it. I want to populate my local SQL database with the data on the IBM = DB2 database. We already requested for a comma-delimited text file of all the data of = all the tables of our database, but the DB admin is not responding. So I = am now trying to just get the data ourselves using CF.. manually. Immediate help will be very much appreciated. Thanks, Winston --=_NextPart_000_020E_01C0A1A1.B3261D40 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable !DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" HTMLHEAD META content=3D"text/html; charset=3Diso-8859-1" = http-equiv=3DContent-Type META content=3D"MSHTML 5.00.2919.6307" name=3DGENERATOR STYLE/STYLE /HEAD BODY bgColor=3D#ff DIV style=3D"FONT: 10pt arial"/DIV DIVFONT face=3DArialHi,/FONT/DIV DIVnbsp;/DIV DIVFONT face=3DArialI'm would like to make a query to each database = table,=20 with a "select *" to output all records. I am going to use CFTABLE to = output the=20 results. Is there any way I can do this wihtout having to specify one by = one the=20 column/field names of that table?/FONT/DIV DIVnbsp;/DIV DIVFONT face=3DArialI am trying to do this since I want to display = or output=20 the whole contents of all the tables in my database, which I am going to = transfer to Excel sheet./FONT/DIV DIVnbsp;/DIV DIVFONT face=3DArialYou see, the data I want to get is on IBM DB2, = which I=20 want to export to my local SQL database. And the DB2 is remote, and I = have no=20 access to it. I want to populate my local SQL database with the data on = the IBM=20 DB2 database./FONT/DIV DIVnbsp;/DIV DIVFONT face=3DArialWe already requested for a comma-delimited text = file of=20 all the data of all the tables of our database, but the DB admin is not=20 responding. So I am now trying to just get the data ourselves using CF.. = manually./FONT/DIV DIVnbsp;/DIV DIVFONT face=3DArialImmediate help will be very much = appreciated./FONT/DIV DIVnbsp;/DIV DIVFONT face=3DArialThanks,/FONT/DIV DIVFONT face=3DArialWinston/FONT/DIV/BODY/HTML --=_NextPart_000_020E_01C0A1A1.B3261D40-- Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists ** The opinions expressed in this E-mail are those of the individual and not necessarily the company. This E-mail and any files transmitted with it are confidential and solely for the use of the intended recipients ** ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Fw: CFQuery of database tables
This is a multi-part message in MIME format. --=_NextPart_000_020E_01C0A1A1.B3261D40 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi, I'm would like to make a query to each database table, with a "select *" = to output all records. I am going to use CFTABLE to output the results. = Is there any way I can do this wihtout having to specify one by one the = column/field names of that table? I am trying to do this since I want to display or output the whole = contents of all the tables in my database, which I am going to transfer = to Excel sheet. You see, the data I want to get is on IBM DB2, which I want to export to = my local SQL database. And the DB2 is remote, and I have no access to = it. I want to populate my local SQL database with the data on the IBM = DB2 database. We already requested for a comma-delimited text file of all the data of = all the tables of our database, but the DB admin is not responding. So I = am now trying to just get the data ourselves using CF.. manually. Immediate help will be very much appreciated. Thanks, Winston --=_NextPart_000_020E_01C0A1A1.B3261D40 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable !DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" HTMLHEAD META content=3D"text/html; charset=3Diso-8859-1" = http-equiv=3DContent-Type META content=3D"MSHTML 5.00.2919.6307" name=3DGENERATOR STYLE/STYLE /HEAD BODY bgColor=3D#ff DIV style=3D"FONT: 10pt arial"/DIV DIVFONT face=3DArialHi,/FONT/DIV DIVnbsp;/DIV DIVFONT face=3DArialI'm would like to make a query to each database = table,=20 with a "select *" to output all records. I am going to use CFTABLE to = output the=20 results. Is there any way I can do this wihtout having to specify one by = one the=20 column/field names of that table?/FONT/DIV DIVnbsp;/DIV DIVFONT face=3DArialI am trying to do this since I want to display = or output=20 the whole contents of all the tables in my database, which I am going to = transfer to Excel sheet./FONT/DIV DIVnbsp;/DIV DIVFONT face=3DArialYou see, the data I want to get is on IBM DB2, = which I=20 want to export to my local SQL database. And the DB2 is remote, and I = have no=20 access to it. I want to populate my local SQL database with the data on = the IBM=20 DB2 database./FONT/DIV DIVnbsp;/DIV DIVFONT face=3DArialWe already requested for a comma-delimited text = file of=20 all the data of all the tables of our database, but the DB admin is not=20 responding. So I am now trying to just get the data ourselves using CF.. = manually./FONT/DIV DIVnbsp;/DIV DIVFONT face=3DArialImmediate help will be very much = appreciated./FONT/DIV DIVnbsp;/DIV DIVFONT face=3DArialThanks,/FONT/DIV DIVFONT face=3DArialWinston/FONT/DIV/BODY/HTML --=_NextPart_000_020E_01C0A1A1.B3261D40-- Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
CFGurus: A CFQuery and database question
htmlDIV PBRok all you CFMasters.I think i have a relatively simple CF question concerning databases and CFQuery. But for the life of me am stumped (4 hours to put it exactly).nbsp; I am trying to build a page with a pull down select menu of different towns in the state of connecticut.nbsp; When the user selects a town (i.e. Plainfield, Smallville...ect.), Inbsp;would like my user to be sent to a cfm "town" page with the corresponding town data (ie. town, organization, population size, event date, ect...).nbsp;The million dollar question is: how do i set up my pull down "town" variables in my code so thatnbsp;when a specific town is selected, i getnbsp;that specific town's information from my database.nbsp; I know conceptually what is going on here but am having trouble with the correct CF coding here. I think it has something to do with setting my town variable up correctly in my inital CFQUERY and in my pull down menu. But cannot pinpoint it./P PBelow is what i have for my CFQUERY coding ,nbsp; my CFOUTPUT coding, as well as coding for my pull down menu.nbsp; nbsp;/P PPlease ANY help,especially with the coding, would be greatly appreciated. Have a safe holiday everyone./P Pnbsp;/P Pthanks, colin/P PHere isnbsp;mynbsp;coding:nbsp;nbsp;/P/DIV DIV/DIV DIVlt;CFQUERY NAME="GetResults" DATASOURCE="Reminder"gt;BRnbsp;SELECT town, organization, headline, body, event_dateBRnbsp;FROM GetResultsBRnbsp;WHEREnbsp;?/DIV DIVnbsp;/DIV DIVnbsp;BRlt;/CFQUERYgt;/DIV DIVnbsp;/DIV DIVnbsp;/DIV DIVlt;CFOUTPUT QUERY = "GetResults"gt;BRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;BRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;Pgt;Town: #town# lt;/Pgt;BRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;Pgt;Organization: #organization# lt;/Pgt;BRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;Pgt;Headline: #headline# lt;/Pgt;BRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;Pgt;Body: #body# lt;/Pgt;BRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;Pgt;Event Date: #event_date# lt;/Pgt;BRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;BRnbsp;lt;/CFOUTPUTgt;/DIV DIVnbsp;/DIV DIVnbsp;/DIV DIVnbsp;/DIV DIVnbsp;/DIV DIV**TOWN PULLDOWN/DIV DIVnbsp;/DIV DIVlt;table border="0" cellpadding="0" cellspacing="0" width="611"gt;BRnbsp;nbsp;nbsp;nbsp;lt;trgt;BRnbsp;nbsp;nbsp;nbsp;nbsp;lt;td width="99"gt;lt;img height="40" width="99" src="images/navhead.gif"gt;lt;/tdgt;BRnbsp;nbsp;nbsp;nbsp;nbsp;lt;td valign="middle"gt;lt;font size="2"gt;BRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;form name="FormName" action="(Empty Reference!)" method="get"gt;BRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;Search:lt;/fontgt;lt;font face="Verdana" size="2"gt; lt;select name="selectName" size="1" tabindex="1"gt;BRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;option value="Manchester" selectedgt;ManchesterBRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;option value="Ashford" selectedgt;AshfordBRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;option value="East Hartford" selectedgt;East HartfordBRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;option value="East Windsor" selectedgt;East WindsorBRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;option value="Ellington" selectedgt;EllingtonBRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;option value="Enfield" selectedgt;EnfieldBRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;option value="Pomfret" selectedgt;PomfretBRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;option value="Somers" selectedgt;SomersBRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;option value="South Windsor" selectedgt;South WindsorBRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;option value="Stafford" selectedgt;StaffordBRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;option value="Stafforville" selectedgt;StafforvilleBRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;option value="Suffield" selectedgt;SuffieldBRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;option value="Tolland" selectedgt;TollandBRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;option value="Vernon" selectedgt;VernonBRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;option value="Warehouse Point" selectedgt;Warehouse PointBRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;option value="West Suffield" selectedgt;West SuffieldBRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;option value="Willington" selectedgt;WillingtonBRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;option value="Windsor" selectedgt;WindsorBRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;option value="Windsor Locks" selectedgt;Windsor LocksBRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;option value="Brooklyn" selectedgt;BrooklynBRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;option value="Chaplin" selectedgt;ChaplinBRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;option value="Colchester" selectedgt;ColchesterBRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;option value="Coventry" selectedgt;CoventryBRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;option value="Danielson" selectedgt;DanielsonBRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;option value="Dayville"
Re: CFGurus: A CFQuery and database question
Well, you can't have ALL towns selected. You need a /select at the end. And try: CFQUERY NAME="GetResults" DATASOURCE="Reminder" SELECT town, organization, headline, body, event_date FROM GetResults WHERE town = '#Form.SelectName#' /CFQUERY best, paul At 08:17 PM 12/29/00 -0500, you wrote: ok all you CFMasters.I think i have a relatively simple CF question concerning databases and CFQuery. But for the life of me am stumped (4 hours to put it exactly). I am trying to build a page with a pull down select menu of different towns in the state of connecticut. When the user selects a town (i.e. Plainfield, Smallville...ect.), I would like my user to be sent to a cfm "town" page with the corresponding town data (ie. town, organization, population size, event date, ect...). The million dollar question is: how do i set up my pull down "town" variables in my code so that when a specific town is selected, i get that specific town's information from my database. I know conceptually what is going on here but am having trouble with the correct CF coding here. I think it has something to do with setting my town variable up correctly in my inital CFQUERY and in my pull down menu. But cannot pinpoint it. Below is what i have for my CFQUERY coding , my CFOUTPUT coding, as well as coding for my pull down menu. Please ANY help,especially with the coding, would be greatly appreciated. Have a safe holiday everyone. thanks, colin Here is my coding: CFQUERY NAME="GetResults" DATASOURCE="Reminder" SELECT town, organization, headline, body, event_date FROM GetResults WHERE ? /CFQUERY CFOUTPUT QUERY = "GetResults" PTown: #town# /P POrganization: #organization# /P PHeadline: #headline# /P PBody: #body# /P PEvent Date: #event_date# /P /CFOUTPUT **TOWN PULLDOWN table border="0" cellpadding="0" cellspacing="0" width="611" tr td width="99"img height="40" width="99" src="images/navhead.gif"/td td valign="middle"font size="2" form name="FormName" action="(Empty Reference!)" method="get" Search:/fontfont face="Verdana" size="2" select name="selectName" size="1" tabindex="1" option value="Manchester" selectedManchester option value="Ashford" selectedAshford option value="East Hartford" selectedEast Hartford option value="East Windsor" selectedEast Windsor option value="Ellington" selectedEllington option value="Enfield" selectedEnfield option value="Pomfret" selectedPomfret option value="Somers" selectedSomers option value="South Windsor" selectedSouth Windsor option value="Stafford" selectedStafford option value="Stafforville" selectedStafforville option value="Suffield" selectedSuffield option value="Tolland" selectedTolland option value="Vernon" selectedVernon option value="Warehouse Point" selectedWarehouse Point option value="West Suffield" selectedWest Suffield option value="Willington" selectedWillington option value="Windsor" selectedWindsor option value="Windsor Locks" selectedWindsor Locks option value="Brooklyn" selectedBrooklyn option value="Chaplin" selectedChaplin option value="Colchester" selectedColchester option value="Coventry" selectedCoventry option value="Danielson" selectedDanielson option value="Dayville" selectedDayville option value="East Haddam" s /form /font/td /tr /table -- Get your FREE download of MSN Explorer at http://explorer.msn.comhttp://explorer.msn.com ~ Paid Sponsorship ~ Get Your Own Dedicated Win2K Server! Instant Activation for $99/month w/Free Setup from SoloServer PIII600 / 128 MB RAM / 20 GB HD / 24/7/365 Tech Support Visit SoloServer, https://secure.irides.com/clientsetup.cfm. Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Re: CFGurus: A CFQuery and database question
You need to put an onChange attribute in your SELECT tag, so that whenever you select an option from the list, that name/value pair is submitted to whatever you specify in your onChange event. script language=javascript function doSub{ this.form.submit; return true; } /script select action=xyz method=post name=abc onChange=doSub(); option value=1klm/option option value=2ijk/option /select Hope that helps Hassan Khawaja www.computerms.com --- C Kong [EMAIL PROTECTED] wrote: htmlDIV PBRok all you CFMasters.I think i have a relatively simple CF question concerning databases and CFQuery. But for the life of me am stumped (4 hours to put it exactly).nbsp; I am trying to build a page with a pull down select menu of different towns in the state of connecticut.nbsp; When the user selects a town (i.e. Plainfield, Smallville...ect.), Inbsp;would like my user to be sent to a cfm "town" page with the corresponding town data (ie. town, organization, population size, event date, ect...).nbsp;The million dollar question is: how do i set up my pull down "town" variables in my code so thatnbsp;when a specific town is selected, i getnbsp;that specific town's information from my database.nbsp; I know conceptually what is going on here but am having trouble with the correct CF coding here. I think it has something to do with setting my town variable up correctly in my inital CFQUERY and in my pull down menu. But cannot pinpoint it./P PBelow is what i have for my CFQUERY coding ,nbsp; my CFOUTPUT coding, as well as coding for my pull down menu.nbsp; nbsp;/P PPlease ANY help,especially with the coding, would be greatly appreciated. Have a safe holiday everyone./P Pnbsp;/P Pthanks, colin/P PHere isnbsp;mynbsp;coding:nbsp;nbsp;/P/DIV DIV/DIV DIVlt;CFQUERY NAME="GetResults" DATASOURCE="Reminder"gt;BRnbsp;SELECT town, organization, headline, body, event_dateBRnbsp;FROM GetResultsBRnbsp;WHEREnbsp;?/DIV DIVnbsp;/DIV DIVnbsp;BRlt;/CFQUERYgt;/DIV DIVnbsp;/DIV DIVnbsp;/DIV DIVlt;CFOUTPUT QUERY = "GetResults"gt;BRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;BRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;Pgt;Town: #town# lt;/Pgt;BRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;Pgt;Organization: #organization# lt;/Pgt;BRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;Pgt;Headline: #headline# lt;/Pgt;BRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;Pgt;Body: #body# lt;/Pgt;BRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;Pgt;Event Date: #event_date# lt;/Pgt;BRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;BRnbsp;lt;/CFOUTPUTgt;/DIV DIVnbsp;/DIV DIVnbsp;/DIV DIVnbsp;/DIV DIVnbsp;/DIV DIV**TOWN PULLDOWN/DIV DIVnbsp;/DIV DIVlt;table border="0" cellpadding="0" cellspacing="0" width="611"gt;BRnbsp;nbsp;nbsp;nbsp;lt;trgt;BRnbsp;nbsp;nbsp;nbsp;nbsp;lt;td width="99"gt;lt;img height="40" width="99" src="images/navhead.gif"gt;lt;/tdgt;BRnbsp;nbsp;nbsp;nbsp;nbsp;lt;td valign="middle"gt;lt;font size="2"gt;BRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;form name="FormName" action="(Empty Reference!)" method="get"gt;BRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;Search:lt;/fontgt;lt;font face="Verdana" size="2"gt; lt;select name="selectName" size="1" tabindex="1"gt;BRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;option value="Manchester" selectedgt;ManchesterBRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;option value="Ashford" selectedgt;AshfordBRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;option value="East Hartford" selectedgt;East HartfordBRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;option value="East Windsor" selectedgt;East WindsorBRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;option value="Ellington" selectedgt;EllingtonBRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;option value="Enfield" selectedgt;EnfieldBRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;option value="Pomfret" selectedgt;PomfretBRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;option value="Somers" selectedgt;SomersBRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;option value="South Windsor" selectedgt;South WindsorBRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;option value="Stafford" selectedgt;StaffordBRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;option value="Stafforville" selectedgt;StafforvilleBRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;option value="Suffield" selectedgt;SuffieldBRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;option value="Tolland" selectedgt;TollandBRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;option value="Vernon" selectedgt;VernonBRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;option value="Warehouse Point" selectedgt;Warehouse PointBRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;option value="West Suffield" selectedgt;West SuffieldBRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;option value="Willington" selectedgt;WillingtonBRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;option value="Windsor" selectedgt;WindsorBRnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;lt;option value="Windsor Locks" selectedgt;Windsor