Multiple Selection

We recently upgraded from Dreamweaver 8 to CS3. For some reason because of the upgrade, I can't view the multiple selections on my  local testing machine. I get a page but no records displaying on the asp page. In DM8, the following SQL statement was written in the advance recordset to allow me to select and input multiple entries and the syntax worked:

  SELECT *
  FROM tblEntries
  WHERE designtype IN (MMColParam)

In the upgrade to CS3, the following SQL statement was shown in the code:

 SELECT *
  FROM tblEntries
  WHERE designtype IN (?)

In the above CS3 SQL statement, I can only select one entry. What does the question mark mean? Why is there a difference? Also, I have a asp page in production that is working using the above DM8 syntax so I'm safe. But I need to know the difference and the correct syntax used for CS3 for this particular form request.

Please advise. Thanks Experts.

 





Browser
5532Asked:
Who is Participating?
 
RouchieConnect With a Mentor Commented:
IF you get an error in v2media's code on the sql line, use an ampersand to concatenate the sql string together instead of a plus symbol...


RsEntries_cmd.CommandText = "SELECT * FROM tblEntries WHERE designtype IN (" & RsEntries__MMColParam & ")"

Open in new window

0
 
Jason C. LevineNo oneCommented:
Hi 5532,

You may need to rebuild the recordset from CS3 to get it to work again.  Adobe changed the way DW writes recordset code slightly from 8 to CS3 and CS3 doesn't always pick up v8 code.
0
 
5532Author Commented:
Hi, jason1178

It has been awhile since you and Rouchie have helped me with the same issue. (I don't know why Adobe had to reinvent the wheel, the wheel wasn't broken.) --- I rebuilt the recordset in CS3. I still can't get the form request to display multiple selection. I get a blank page, no error message.

Here is the CS3 code:

<%
Dim RsEntries__MMColParam
RsEntries__MMColParam = "0"
If (Request.Form("sltEntries") <> "") Then
  RsEntries__MMColParam = Request.Form("sltEntries")
End If
%>
<%
Dim RsEntries
Dim RsEntries_cmd
Dim RsEntries_numRows

Set RsEntries_cmd = Server.CreateObject ("ADODB.Command")
RsEntries_cmd.ActiveConnection = MM_Entries_STRING
RsEntries_cmd.CommandText = "SELECT * FROM  tblEntries WHERE designtype IN (?)"
RsEntries_cmd.Prepared = true
RsEntries_cmd.Parameters.Append RsEntries_cmd.CreateParameter("param1", 200, 1, 255, RsEntries__MMColParam) ' adVarChar

Set RsEntries= RsEntries_cmd.Execute
RsEntries_numRows = 0
%>
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
Jason C. LevineNo oneCommented:
Hmm.

Try this:
<%
Dim RsEntries__MMColParam
RsEntries__MMColParam = "0"
If (Request.Form("sltEntries") <> "") Then
  RsEntries__MMColParam = Request.Form("sltEntries")
End If
%>
<%
Dim RsEntries
Dim RsEntries_cmd
Dim RsEntries_numRows
 
Set RsEntries_cmd = Server.CreateObject ("ADODB.Command")
RsEntries_cmd.ActiveConnection = MM_Entries_STRING
RsEntries_cmd.CommandText = "SELECT * FROM  tblEntries WHERE designtype IN (RsEntries__MMColParam)"
RsEntries_cmd.Prepared = true
RsEntries_cmd.Parameters.Append RsEntries_cmd.CreateParameter("param1", 200, 1, 255, RsEntries__MMColParam) ' adVarChar
 
Set RsEntries= RsEntries_cmd.Execute
RsEntries_numRows = 0
%>

Open in new window

0
 
5532Author Commented:
I replaced SELECT * FROM  tblEntries WHERE designtype IN (?)  with SELECT * FROM  tblEntries WHERE designtype IN (RsEntries__MMColParam). I received the following error message:

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E10)
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
0
 
Jason C. LevineNo oneCommented:
I think we need someone better versed in ASP than me.  As far as I can tell, that should have worked, unless the IN syntax is wrong...
0
 
5532Author Commented:
I agree with you. I believe it is in the IN syntax. CS3 re-wrote that part of the code. I'm checking in now with Adobe.
0
 
Jason C. LevineNo oneCommented:
Try this:

SELECT * FROM  tblEntries WHERE designtype = (RsEntries__MMColParam)

instead
0
 
RouchieCommented:
Sorry for the late entry folks; it's been one of those weeks...

The IN syntax won't work because (in SQL anyway) you can't pass a string of values as an array directly to a SELECT function.  Therefore you should use = instead of IN

Try this out and let us know what happens.  If it doesn't work we can always scrap DW's attempts at SQL and rewrite it from scratch...
<%
Dim RsEntries__MMColParam
RsEntries__MMColParam = "0"
If (Request.Form("sltEntries") <> "") Then
  RsEntries__MMColParam = Request.Form("sltEntries")
End If
Dim RsEntries
Dim RsEntries_cmd
Dim RsEntries_numRows
Set RsEntries_cmd = Server.CreateObject ("ADODB.Command")
RsEntries_cmd.ActiveConnection = MM_Entries_STRING
RsEntries_cmd.CommandText = "SELECT * FROM  tblEntries WHERE designtype = ?"
RsEntries_cmd.Prepared = true
RsEntries_cmd.Parameters.Append RsEntries_cmd.CreateParameter("param1", 200, 1, 255, RsEntries__MMColParam) ' adVarChar
Set RsEntries= RsEntries_cmd.Execute
RsEntries_numRows = 0
%>

Open in new window

0
 
v2MediaCommented:
The code Jason posted should work as long as the string passed by "sltEntries" is a comma separated list of ints yes?

What's an example post/get value of the form field "sltEntries" after the form is submitted?
0
 
RouchieCommented:
5532 which database platform are you using?  

In SQL Server you cannot pass an array directly to a SQL select statement from ASP (see CAUSE text at http://support.microsoft.com/kb/555266).  You've either got to pass XML or use additional SQL statements to break up the array into a temporary table that the IN clause then functions with.

I'm not sure whether this rule applies to MySQL and Access.
0
 
v2MediaCommented:
MySQL yes, access JET sql doesn't include "IN"
0
 
RouchieCommented:
>> MySQL yes

Interesting.  I though MySQL and SQL Server were much more similar than that in their underlying workings...  :-/
0
 
Jason C. LevineNo oneCommented:
Hey boys,

Check out the new all-time point total...

J
0
 
5532Author Commented:
Hello Everyone -- Thanks for responding --
I have one directory of the application for sql server and another for access. In DW8, I was able through Rouchie's previous help use IN (MMColParam) in my SQL statement in the asp page and it worked in both situations. Also, I have a working prototype in development and currently being tested using DW8's syntax and it is working---which I'm not going to touch. Now its not working in CS3 since we upgraded--I like to figure this out with your help. Here is what I've done since your responses:

  Jason1178 post @ 01.29.2008 at 05:57PM PST, ID: 20774049
  SELECT * FROM  tblEntries WHERE designtype = (RsEntries__MMColParam)
  Error Message-- Microsoft OLE DB Provider for ODBC Drivers (0x80040E10)
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.

Rouchies posts @ 01.30.2008 at 01:24AM PST, ID: 20775719
-- I replaced IN with = and I'm only able to select one entry to display.
0
 
5532Author Commented:
Let me try something per:

v2Media:The code Jason posted should work as long as the string passed by "sltEntries" is a comma separated list of ints yes?

What's an example post/get value of the form field "sltEntries" after the form is submitted?

0
 
5532Author Commented:
I tried both post and get--no change. Still not able to display multple results.
0
 
Jason C. LevineNo oneCommented:
>> -- I replaced IN with = and I'm only able to select one entry to display.

You do have a repeat region on the page to display multiple results, right?
0
 
5532Author Commented:
Yes, I have the repeat region.
0
 
Jason C. LevineNo oneCommented:
Okay, just didn't want to overlook the obvious.

From the error message you get when you tried my code, it's obvious that something is not being passed properly to the query.  The other two guys are much better with this part of DW than I am, so I'm going to bow out here.
0
 
5532Author Commented:
Thanks for your input, jason1178.
0
 
v2MediaCommented:
Guys, I was on the right track before. ODBC SQL grammar, with access, includes the IN clause, "IN (valuelist)". So, to ensure the sql statement has the proper syntax, you have to ensure "sltEntries" is a comma separated list.

If RsEntries__MMColParam is getting its string value from the form value "sltEntries", then sltEntries must be a string with the format  "1,2,3,4". Deviating from that format will result in a sql syntax error.

For reference, check out "Additional Supported ODBC SQL Grammar" at msdn.
0
 
5532Author Commented:
Thanks, v2Media--I was just looking at the reference. The problem is getting Dreamweaver to accept the sql syntax. I just tried hardcoding the recommendations from this discussion and it still appears the newer version of dw doesn't know what to do with it.

additional references:
http://msdn2.microsoft.com/en-us/library/ms177563.aspx
0
 
v2MediaCommented:
OK, so your left with two choices. Change the sql query to a form that DW understands or leave it as is and move forward.

Personally I wouldn't let a project get bogged down by DW. If the code works, move forward; it's more profitable. The end product, and the client, aren't going to give a toss if DW cant cope with the code.
0
 
RouchieCommented:
>>Hey boys,
>>Check out the new all-time point total...
>>J

Nice work, sir!  I won't be bowing down though as your profile suggests we should.  Merely concentrating on promoting ASP.NET so I stand a chance of keeping up...  ;-)

5532 Can you post the complete code for the page?  I'm going to make some alterations that allow us to see just what the heck DW is trying to do!
0
 
5532Author Commented:
Thanks Rouchie for not bowing down or out. BTW, I took a visual studio C# .Net class-- I can see why in our last discussion for a different issue you recommended going this route. I was able to create my first aspx page in vs which inserted records but I had to tinker with the code in the back end to enable the TSQL insert. Unfortunately, my boss has decided to put a hold on furhter learning on vs C# .net. I'm going to try to learn this on my own. Anyways.............

Here is the code:

Here is the CS3 DW code:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="../Connections/Entries.asp" -->
<%
Dim RsEntries__MMColParam
RsEntries__MMColParam = "0"
If (Request.Form("sltForm")     <> "") Then
  RsEntries__MMColParam = Request.Form("sltForm")    
End If
%>
<%
Dim RsEntries
Dim RsEntries_cmd
Dim RsEntries_numRows

Set RsEntries_cmd = Server.CreateObject ("ADODB.Command")
RsEntries_cmd.ActiveConnection = MM_Entries_STRING
RsEntries_cmd.CommandText = "SELECT * FROM tblEntries WHERE designtype IN (?) " 
RsEntries_cmd.Prepared = true
RsEntries_cmd.Parameters.Append RsEntries_cmd.CreateParameter("param1", 200, 1, 255, RsEntries__MMColParam) ' adVarChar

Set RsEntries = RsEntries_cmd.Execute
RsEntries_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = 20
Repeat1__index = 0
RsEntries_numRows = RsEntries_numRows + Repeat1__numRows
%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>View list of all eforms</title>
<link href="Entries.css" rel="stylesheet" type="text/css" />
</head>
<body>

<span class="style6"></span><span class="style6"></span>
<% If Not RsEntries.EOF Or Not RsEntries.BOF Then %>
  <table width="100%" border="0" cellpadding="3" cellspacing="0">
    <tr bgcolor="#CCCCCC">
      <td align="center" nowrap="nowrap" class="bold4">Number (pdf) </td>
      <td align="center" nowrap="nowrap" class="bold4">Title</td>
          </tr>
    <% While ((Repeat1__numRows <> 0) AND (NOT RsEntries.EOF)) %>
      <tr bgcolor="#CCFFFF">
        <td align="center" nowrap="nowrap" class="style4"><a href="<%=(RsEntries.Fields.Item("brochurepdf").Value)%>" target="_blank" class="style4"><%=(RsEntries.Fields.Item("designtype").Value)%></a></td>
        <td nowrap="nowrap"><span class="style4"><%=(RsEntries.Fields.Item("ProductTitle").Value)%></span>&nbsp;</td>
       
      </tr>
 
        <%
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  RsEntries.MoveNext()
Wend
%>
  </table>
  <% End If ' end Not RsEntries.EOF Or NOT RsEntries.BOF %>
</body>
</html>
<%
RsEntries.Close()
Set RsEntries = Nothing
%>
0
 
RouchieCommented:
Okay let's first make sure that the page is grabbing the form data properly.

Change this

If (Request.Form("sltForm")     <> "") Then
  RsEntries__MMColParam = Request.Form("sltForm")    
End If

to this

If (Request.Form("sltForm")     <> "") Then
  RsEntries__MMColParam = Request.Form("sltForm")    
  Response.Write("<!-- " & RsEntries__MMColParam & " -->")
End If

Then run the page and post the form.  When the page reloads, view the source code and at the top of the source code you should see the comment.  Please copy and paste what shows up there.
0
 
5532Author Commented:
Page reloads with no visible comments.
0
 
5532Author Commented:
in the source code view : <!-- 1020, 10201, 10203 -->
0
 
RouchieCommented:
Okay then let's rewrite the ASP code to manually include this data.

Change this code block:

Set RsEntries_cmd = Server.CreateObject ("ADODB.Command")
RsEntries_cmd.ActiveConnection = MM_Entries_STRING
RsEntries_cmd.CommandText = "SELECT * FROM tblEntries WHERE designtype IN (?) "
RsEntries_cmd.Prepared = true
RsEntries_cmd.Parameters.Append RsEntries_cmd.CreateParameter("param1", 200, 1, 255, RsEntries__MMColParam) ' adVarChar
Set RsEntries = RsEntries_cmd.Execute

to say this:

Set RsEntries_cmd = Server.CreateObject ("ADODB.Command")
RsEntries_cmd.ActiveConnection = MM_Entries_STRING
RsEntries_cmd.CommandText = "SELECT * FROM tblEntries WHERE designtype IN (" & RsEntries__MMColParam & ")"
Set RsEntries = RsEntries_cmd.Execute

Open in new window

0
 
5532Author Commented:
I received the following error message when I changed the code as shown above in Rouchie's ref post 02.01.2008 at 01:03AM PST, ID: 20795120 :
Microsoft OLE DB Provider for ODBC Drivers (0x80040E07)
[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.

Rouchie previous comment: "In SQL Server you cannot pass an array directly to a SQL select statement from ASP (see CAUSE text at http://support.microsoft.com/kb/555266).  You've either got to pass XML or use additional SQL statements to break up the array into a temporary table that the IN clause then functions with."

I ran a query in SQL server:
Select *
From tblEntries
Where designtype IN (10200,10201,10203)
I did received the data information. Question: How does asp in DW know to parse the numbers and commas? I'm  probably getting data mismatch error  because DW asp is not able to pass the array as you pointed out.
0
 
5532Author Commented:
I re-run the code:
Set RsEntries_cmd = Server.CreateObject ("ADODB.Command")
RsEntries_cmd.ActiveConnection = MM_Entries_STRING
RsEntries_cmd.CommandText = "SELECT * FROM tblEntries WHERE designtype IN (" & RsEntries__MMColParam & ")"
Set RsEntries = RsEntries_cmd.Execute
 
I received this error message:
Open in New Window

Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'designtype IN ()'.
0
 
v2MediaCommented:
DW will not parse the string var into a comma separated list for you. This has to be done on the page that submits the form with the field "sltEntries", or with vbs before the final recordset is generated.

Could you post the source of the first page that submits the form value "sltEntries" plz? Might be time to check your form logic. I'm trying to recreate your forms to interact with a test db.

0
 
5532Author Commented:
Here is the first form page. I appreciate your help:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/Entries.asp" -->
<%
Dim rsEntries
Dim rsEntries_numRows

Set rsEntries = Server.CreateObject("ADODB.Recordset")
rsEntries.ActiveConnection = MM_Entries_STRING
rsEntries.Source = "SELECT * FROM tblEntries"
rsEntries.CursorType = 0
rsEntries.CursorLocation = 2
rsEntries.LockType = 1
rsEntries.Open()

rsEntries_numRows = 0
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Search</title>
<link href="entries.css" rel="stylesheet" type="text/css" />

</head>

<body>
<form action="DisplayEntries.asp" method="post" name="form1" target="_blank" id="form1">
    <fieldset>
      <legend class="style6blue">Search by Design Type and Title</legend>
     <span class="style2">To select multiple Design Type Number and Title click and hold "Ctrl" on keyboard and with mouse pointer scroll, click and select choices then submit. </span><br /><br />
 <label>
  <select name="sltForm" size="10" multiple="multiple" class="style4" id="sltForm">
    <option value="000">Design Type Number - Title</option>
<%
While (NOT rsEntries.EOF)
%>
<option value="<%=(rsEntries.Fields.Item("designtype").Value)%>"><%=(rsEntries.Fields.Item("designtype").Value) & " - " & (rsEntries.Fields.Item("Title").Value)%></option>
    <%
  rsEntries.MoveNext()
Wend
If (rsEntries.CursorType > 0) Then
  rsEntries.MoveFirst
Else
  rsEntries.Requery
End If
%>
  </select>
  <br />
  <input name="Submit" type="submit" class="style4" value="Display Choices" />
 
  <input name="Submit2" type="reset" class="style4" value="Reset" />
  </label>
 </fieldset>
 </form>
</body>
</html>
<%
rsEntries.Close()
Set rsEntries = Nothing
%>

0
 
Jason C. LevineNo oneCommented:
v2 or Rouchie,

How do you tell an ASP form to store values to an array?  In PHP, we would alter the <select> like so:

<select name="sltForm[]" size="10" multiple="multiple" class="style4" id="sltForm">

The addition of the square brackets in the name param tells the server to store multiple selections as a comma-separated string.

5532, you may want to try the above line or wait until you hear back from the ASP guys.
0
 
v2MediaCommented:
Correction, asp will output form fields of the same name into a comma separated list for you.

I have a successful working version here. I select the records to display from page1 form using checkboxes with values of the table column 'id'. Checkboxes are all called name="id". Page 2 form picks up the form list Request.Form("id") and outputs it into the query. Works a treat.

What was screwing up the query was the line:

rsUpdateUsers_cmd.Parameters.Append rsUpdateUsers_cmd.CreateParameter("param1", 5, 1, -1, rsUpdateUsers__MMColParam) ' adDouble

I saw no reason for this asp function. The string is already nicely formatted. So I suggest using the following code from your original post as long as the form your posting from has the form inputs named "sltEntries". All that has been changed is the deletion of the CreateParameter line:-
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="../Connections/Entries.asp" -->
<%
Dim RsEntries__MMColParam
RsEntries__MMColParam = "1"
If (Request.Form("sltForm") <> "") Then
  RsEntries__MMColParam = Request.Form("sltForm")    
End If
%>
<%
Dim RsEntries
Dim RsEntries_cmd
Dim RsEntries_numRows
 
Set RsEntries_cmd = Server.CreateObject ("ADODB.Command")
RsEntries_cmd.ActiveConnection = MM_Entries_STRING
RsEntries_cmd.CommandText = "SELECT * FROM tblEntries WHERE designtype IN (" & RsEntries__MMColParam & ") "
RsEntries_cmd.Prepared = true
Set RsEntries = RsEntries_cmd.Execute
RsEntries_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index
 
Repeat1__numRows = 20
Repeat1__index = 0
RsEntries_numRows = RsEntries_numRows + Repeat1__numRows
%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>View list of all eforms</title>
<link href="Entries.css" rel="stylesheet" type="text/css" />
</head>
<body>
 
<span class="style6"></span><span class="style6"></span>
<% If Not RsEntries.EOF Or Not RsEntries.BOF Then %>
  <table width="100%" border="0" cellpadding="3" cellspacing="0">
    <tr bgcolor="#CCCCCC">
      <td align="center" nowrap="nowrap" class="bold4">Number (pdf) </td>
      <td align="center" nowrap="nowrap" class="bold4">Title</td>
          </tr>
    <% While ((Repeat1__numRows <> 0) AND (NOT RsEntries.EOF)) %>
      <tr bgcolor="#CCFFFF">
        <td align="center" nowrap="nowrap" class="style4"><a href="<%=(RsEntries.Fields.Item("brochurepdf").Value)%>" target="_blank" class="style4"><%=(RsEntries.Fields.Item("designtype").Value)%></a></td>
        <td nowrap="nowrap"><span class="style4"><%=(RsEntries.Fields.Item("ProductTitle").Value)%></span>&nbsp;</td>
       
      </tr>
 
        <%
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  RsEntries.MoveNext()
Wend
%>
  </table>
  <% End If ' end Not RsEntries.EOF Or NOT RsEntries.BOF %>
</body>
</html>
<%
RsEntries.Close()
Set RsEntries = Nothing
%>

Open in new window

0
 
5532Author Commented:
I used the brackets but can only display one selection. When I select and submit multiple entries, I receive a blank page.
0
 
Jason C. LevineNo oneCommented:
Okay, that's a PHP only function then.  
0
 
5532Author Commented:
v2Media:
Question: Will this work also with a list field menu? There is over 700 records in SQL server with each record having its own id reference. The list field menu will take less real estate.
0
 
5532Author Commented:
Still did not pass. I am not sure why the scripts are not working. The asp page I built prior to this question to you all was working. I don't understand how CS3 could affect syntax. I didn't make any changes except open the page in CS3. My localhost is working and I checked IIS and IUSR---the configurations are there.
0
 
v2MediaConnect With a Mentor Commented:
The syntax is affected by the parameters passed in the function CreateParameter. DW writes the arguements to this function when you create the recordset and the resulting values for these arguments depend on what was entered into the RS dialog box. When you go playing with with the var MMColParam, the arguements for CreateParameter more than likely conflict. So the final sql is rejected by the odbc driver.

Will the logic work with a muli-select option? Sure Does. Here's a multi-select list version I have working on my system:
#FILE: formSelect.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="Connections/connQ23121097.asp" -->
<%
Dim rsUsers
Dim rsUsers_cmd
Dim rsUsers_numRows
 
Set rsUsers_cmd = Server.CreateObject ("ADODB.Command")
rsUsers_cmd.ActiveConnection = MM_connQ23121097_STRING
rsUsers_cmd.CommandText = "SELECT * FROM users" 
rsUsers_cmd.Prepared = true
 
Set rsUsers = rsUsers_cmd.Execute
rsUsers_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index
 
Repeat1__numRows = -1
Repeat1__index = 0
rsUsers_numRows = rsUsers_numRows + Repeat1__numRows
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Form Select</title>
</head>
 
<body>
<form id="form1" name="form1" method="post" action="selectDisplay.asp">
  <p>Select Users to Edit: </p>
  <table width="400" border="0" cellspacing="1" cellpadding="2">
    <tr>
      <td width="264"><select name="id" size="3" multiple="multiple" id="id">
        <%
While (NOT rsUsers.EOF)
%>
        <option value="<%=(rsUsers.Fields.Item("id").Value)%>" <%If (Not isNull((rsUsers.Fields.Item("id").Value))) Then If (CStr(rsUsers.Fields.Item("id").Value) = CStr((rsUsers.Fields.Item("id").Value))) Then Response.Write("selected=""selected""") : Response.Write("")%> ><%=( rsUsers.Fields.Item("fName").Value + " " + rsUsers.Fields.Item("lName").Value ) %> </option>
        <%
  rsUsers.MoveNext()
Wend
If (rsUsers.CursorType > 0) Then
  rsUsers.MoveFirst
Else
  rsUsers.Requery
End If
%>
      </select>
</td>
      <td width="125" valign="top"><div align="right">
        <input type="submit" name="Submit" id="Submit" value="Submit" />
      </div></td>
    </tr>
  </table>
  <p>&nbsp;  </p>
</form>
</body>
</html>
<%
rsUsers.Close()
Set rsUsers = Nothing
%>
 
#FILE: selectDisplay.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="Connections/connQ23121097.asp" -->
<%
Dim rsUpdateUsers__MMColParam
rsUpdateUsers__MMColParam = "1"
If (Request.Form("id") <> "") Then 
  rsUpdateUsers__MMColParam = Request.Form("id")
End If
%>
<%
Dim rsUpdateUsers
Dim rsUpdateUsers_cmd
Dim rsUpdateUsers_numRows
 
Set rsUpdateUsers_cmd = Server.CreateObject ("ADODB.Command")
rsUpdateUsers_cmd.ActiveConnection = MM_connQ23121097_STRING
rsUpdateUsers_cmd.CommandText = "SELECT * FROM users WHERE id IN (" & rsUpdateUsers__MMColParam & ") ORDER BY fName ASC" 
rsUpdateUsers_cmd.Prepared = true
 
Set rsUpdateUsers = rsUpdateUsers_cmd.Execute
rsUpdateUsers_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index
 
Repeat1__numRows = -1
Repeat1__index = 0
rsUpdateUsers_numRows = rsUpdateUsers_numRows + Repeat1__numRows
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Selected Display</title>
</head>
 
<body>
<p>The previous form submitted the id string: <%= Request.Form("id") %></p>
<p>SQL = <% Response.Write( rsUpdateUsers_cmd.CommandText ) %></p>
<form id="form1" name="form1" method="post" action="">
  <table border="0" cellspacing="1" cellpadding="2">
    <tr>
      <th scope="col">First Name</th>
      <th scope="col">Last Name</th>
      <th scope="col">UserName</th>
      <th scope="col">Password</th>
    </tr>
    <% 
While ((Repeat1__numRows <> 0) AND (NOT rsUpdateUsers.EOF)) 
%>
      <tr>
        <td><input name="fName" type="text" id="fName" value="<%=(rsUpdateUsers.Fields.Item("fName").Value)%>" /></td>
        <td><input name="lName" type="text" id="lName" value="<%=(rsUpdateUsers.Fields.Item("lName").Value)%>" /></td>
        <td><input name="uName" type="text" id="uName" value="<%=(rsUpdateUsers.Fields.Item("uName").Value)%>" /></td>
        <td><input name="passWord" type="text" id="passWord" value="<%=(rsUpdateUsers.Fields.Item("passWord").Value)%>" /></td>
      </tr>
      <% 
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  rsUpdateUsers.MoveNext()
Wend
%>
<tr>
      <td colspan="4"><div align="right">
        <label>Update Users&nbsp;&nbsp;&gt;&gt;&gt;
        <input type="submit" name="Submit" id="Submit" value="UPDATE" />
        </label>
      </div></td>
    </tr>
  </table>
</form>
</body>
</html>
<%
rsUpdateUsers.Close()
Set rsUpdateUsers = Nothing
%>

Open in new window

0
 
v2MediaConnect With a Mentor Commented:
Here's my example worked into your pages. Works fine on my system:
#file 1: select entries
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="../Connections/Entries.asp" -->
<%
Dim rsEntries
Dim rsEntries_numRows
 
Set rsEntries = Server.CreateObject("ADODB.Recordset")
rsEntries.ActiveConnection = MM_Entries_STRING
rsEntries.Source = "SELECT * FROM tblEntries"
rsEntries.CursorType = 0
rsEntries.CursorLocation = 2
rsEntries.LockType = 1
rsEntries.Open()
 
rsEntries_numRows = 0
%>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Search</title>
<link href="entries.css" rel="stylesheet" type="text/css" />
 
</head>
 
<body>
<form action="DisplayEntries.asp" method="post" name="form1" target="_blank" id="form1">
    <fieldset>
      <legend class="style6blue">Search by Design Type and Title</legend>
     <span class="style2">To select multiple Design Type Number and Title click and hold "Ctrl" on keyboard and with mouse pointer scroll, click and select choices then submit. </span><br /><br />
 <label>
  <select name="sltForm" size="10" multiple="multiple" class="style4" id="sltForm">
    <option value="000">Design Type Number - Title</option>
<%
While (NOT rsEntries.EOF)
%>
<option value="<%=(rsEntries.Fields.Item("designtype").Value)%>"><%=(rsEntries.Fields.Item("designtype").Value) & " - " & (rsEntries.Fields.Item("Title").Value)%></option>
    <%
  rsEntries.MoveNext()
Wend
If (rsEntries.CursorType > 0) Then
  rsEntries.MoveFirst
Else
  rsEntries.Requery
End If
%>
  </select>
  <br />
  <input name="Submit" type="submit" class="style4" value="Display Choices" />
 
  <input name="Submit2" type="reset" class="style4" value="Reset" />
  </label>
 </fieldset>
 </form>
</body>
</html>
<%
rsEntries.Close()
Set rsEntries = Nothing
%>
 
 
#File 2: display entries
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="../Connections/Entries.asp" -->
<%
Dim RsEntries__MMColParam
RsEntries__MMColParam = "0"
If (Request.Form("sltForm")     <> "") Then
  RsEntries__MMColParam = Request.Form("sltForm")    
End If
%>
<%
Dim RsEntries
Dim RsEntries_cmd
Dim RsEntries_numRows
 
Set RsEntries_cmd = Server.CreateObject ("ADODB.Command")
RsEntries_cmd.ActiveConnection = MM_Entries_STRING
RsEntries_cmd.CommandText = "SELECT * FROM tblEntries WHERE designtype IN (" + RsEntries__MMColParam + " ) "
RsEntries_cmd.Prepared = true
 
Set RsEntries = RsEntries_cmd.Execute
RsEntries_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index
 
Repeat1__numRows = 20
Repeat1__index = 0
RsEntries_numRows = RsEntries_numRows + Repeat1__numRows
%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>View list of all eforms</title>
<link href="Entries.css" rel="stylesheet" type="text/css" />
</head>
<body>
 
<span class="style6"></span><span class="style6"></span>
<% If Not RsEntries.EOF Or Not RsEntries.BOF Then %>
  <table width="100%" border="0" cellpadding="3" cellspacing="0">
    <tr bgcolor="#CCCCCC">
      <td align="center" nowrap="nowrap" class="bold4">Number (pdf) </td>
      <td align="center" nowrap="nowrap" class="bold4">Title</td>
          </tr>
    <% While ((Repeat1__numRows <> 0) AND (NOT RsEntries.EOF)) %>
      <tr bgcolor="#CCFFFF">
        <td align="center" nowrap="nowrap" class="style4"><a href="<%=(RsEntries.Fields.Item("brochurepdf").Value)%>" target="_blank" class="style4"><%=(RsEntries.Fields.Item("designtype").Value)%></a></td>
        <td nowrap="nowrap"><span class="style4"><%=(RsEntries.Fields.Item("ProductTitle").Value)%></span>&nbsp;</td>
       
      </tr>
 
        <%
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  RsEntries.MoveNext()
Wend
%>
  </table>
  <% End If ' end Not RsEntries.EOF Or NOT RsEntries.BOF %>
</body>
</html>
<%
RsEntries.Close()
Set RsEntries = Nothing
%>

Open in new window

0
 
5532Author Commented:
Thanks. I like to try your code recommendations at work with CS3 on my local machine on Monday. I read your earlier comment and I agree -- I shouldn't focus too much on DW but something has changed on my machine. I will respond shortly. Thanks again.
0
 
5532Author Commented:
v2Media and Rouchie: Is it possible to give each of you 500 hundred points? How do I do that?

I have a question: For my own knowledge: How does the scripts know that a certain field in a database should be either numerical or text. I looked at the asp code and I see no apparent indication that a particular data form request should be either numerical or text. In MS Access I could set it to either numerical or text depending in the data and SQL server after importing access data nvarchar().

0
 
Jason C. LevineNo oneCommented:
>> Is it possible to give each of you 500 hundred points?

No, sorry. You would have to split the points down the middle for them.

Don't worry about it.  I'm in no hurry to have either one of them catch up to me :)
0
 
v2MediaConnect With a Mentor Commented:
5532, all html form fields post/get as strings. It is up to the developer to send values in queries as either string or numeric. It's good practice to print out a schematic diagram of your database while developing a site so when you're designing server behaviours for data manipulation, you know whether to treat a form field as numeric or string.

The Insert and Update behavior dialog box, and recordset when using get/post vars for WHERE clauses, gives you the option of what format each field should take; text, date, numeric etc. DW uses the function GetSQLValueString() to format the variable for the sql query string.
0
All Courses

From novice to tech pro — start learning today.