Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing value to CommandText??

Status
Not open for further replies.

humbleprogrammer

Programmer
Oct 30, 2002
315
US
Hi,

I am trying to pass a value to a DataSets CommandText. I am trying to pass a sort value. Below is my code but it's giving me an error that 'SortField' is not defined. Can someone help?

Thanks in advance!!

<SCRIPT language=&quot;VB&quot;>
Dim SortField
SortField = Request.QueryString(&quot;SortField&quot;)
</SCRIPT>
Code:
<MM:DataSet 
id=&quot;dsSatisfaction&quot;
runat=&quot;Server&quot;
IsStoredProcedure=&quot;false&quot;
ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSettings(&quot;MM_CONNECTION_STRING_objConnMeritas&quot;) %>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSettings(&quot;MM_CONNECTION_DATABASETYPE_objConnMeritas&quot;) %>'
CommandText='<%# &quot;SELECT *  FROM qm ORDER BY &quot; & SortField & &quot; ASC&quot; %>'
CurrentPage='<%# IIf((Request.QueryString(&quot;dsSatisfaction_CurrentPage&quot;) <> Nothing), Request.QueryString(&quot;dsSatisfaction_CurrentPage&quot;), 0)   %>'
PageSize=&quot;20&quot;
Debug=&quot;true&quot;
> 
</MM:DataSet>

 
You need to check that the sortfield is being passed.

Dim Sortfield
if Request.QueryString(&quot;SortField&quot;) <> &quot;&quot; Then
SortField = Request.QueryString(&quot;SortField&quot;)
else
Sortfield = 1
end if

Cheech

[Peace][Pipe]
 
Hello,

Yes, I have tried that and have tried below

Code:
Dim Sortfield
If Request.QueryString(&quot;SortField&quot;) <> Nothing Then
SortField = Request.QueryString(&quot;SortField&quot;)
Else
Sortfield = &quot;Firm&quot;
End If

I still receive the error &quot;Name 'SortField' field is not declared&quot;

Any ideas??

Thanks!

 
typo:
Dim Sortfield

and called
SortField=...

> need more info?
:: don't click HERE ::
 
It was actually a typo in my post. I have it correct in my page. See below for the entire code. Should I be declaring SortField somewhere else?

Code:
<?xml version=&quot;1.0&quot; encoding=&quot;iso-8859-1&quot;?>
<!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;>[/URL]
<%@ Page Language=&quot;VB&quot; ContentType=&quot;text/html&quot; ResponseEncoding=&quot;iso-8859-1&quot; %>
<%@ Register TagPrefix=&quot;MM&quot; Namespace=&quot;DreamweaverCtrls&quot; Assembly=&quot;DreamweaverCtrls,version=1.0.0.0,publicKeyToken=836f606ede05d46a,culture=neutral&quot; %>

<Script language=&quot;VB&quot; runat=&quot;server&quot;>
Dim SortField
If Request.QueryString(&quot;SortField&quot;) <> &quot;&quot; Then
SortField = Request.QueryString(&quot;SortField&quot;)
Else
SortField = &quot;[Member_Recd::Firm_40_char_long]&quot;
End If
</Script>

<MM:DataSet 
id=&quot;dsSatisfaction&quot;
runat=&quot;Server&quot;
IsStoredProcedure=&quot;false&quot;
ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSettings(&quot;MM_CONNECTION_STRING_objConnMeritas&quot;) %>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSettings(&quot;MM_CONNECTION_DATABASETYPE_objConnMeritas&quot;) %>'
CommandText='<%# &quot;SELECT *  FROM qm ORDER BY &quot; & SortField & &quot; ASC&quot; %>'
CurrentPage='<%# IIf((Request.QueryString(&quot;dsSatisfaction_CurrentPage&quot;) <> Nothing), Request.QueryString(&quot;dsSatisfaction_CurrentPage&quot;), 0)   %>'
PageSize=&quot;20&quot;
Debug=&quot;true&quot;
> 
</MM:DataSet>
<MM:PageBind runat=&quot;server&quot; PostBackBind=&quot;true&quot; />

<html xmlns=&quot;[URL unfurl="true"]http://www.w3.org/1999/xhtml&quot;>[/URL]
<head>
<title>Satisfaction Index</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot; />
<link rel=&quot;stylesheet&quot; href=&quot;gosmart.css&quot; type=&quot;text/css&quot;>
</head>
<body>
<table width=&quot;760&quot;>
  <tr>
    <td> 
      <img src=&quot;images/m-logo.gif&quot; width=&quot;289&quot; height=&quot;99&quot;><img src=&quot;images/i-top.jpg&quot; width=&quot;439&quot; height=&quot;94&quot;>
    </td>
  </tr>
 </table>

<form runat=&quot;server&quot;>
<ASP:Repeater runat=&quot;server&quot; ID=&quot;rpSatisfaction&quot; DataSource='<%# dsSatisfaction.DefaultView %>'>
<HeaderTemplate>
<table width=&quot;760&quot; border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot;>
		<tr>
			<th>Firm</th>
			<th align=&quot;center&quot; valign=&quot;middle&quot;>Referrals Received</th>
			<th align=&quot;center&quot; valign=&quot;middle&quot;>Quality Monitoring Rating Average</th>
			<th align=&quot;center&quot; valign=&quot;middle&quot;>Cost Rating Average</th>
		</tr>
		<tr>
		<td colspan=&quot;4&quot;><hr noshade=&quot;noshade&quot; /></td>
		</tr>
</HeaderTemplate>
    <ItemTemplate> 
        <tr> 
          <td nowrap> <a href=&quot;srcfirm_detail.asp?FirmID=<%# dsSatisfaction.FieldValue(&quot;Member_Received&quot;, Container) %>&quot;><%# dsSatisfaction.FieldValue(&quot;Member_Recd::Firm_40_char_long&quot;, Container) %></a>
            <br> <%# dsSatisfaction.FieldValue(&quot;Member_Recd::City_for_Web_Site&quot;, Container) %>
            , 
            <%# dsSatisfaction.FieldValue(&quot;Member_Recd::STATE&quot;, Container) %> <%# dsSatisfaction.FieldValue(&quot;Member_Recd::Country&quot;, Container) %> </td>
          <td align=&quot;center&quot; valign=&quot;middle&quot;> <div align=&quot;center&quot;> 
              <%# dsSatisfaction.FieldValue(&quot;Received_count&quot;, Container) %>
            </div></td>
          <td align=&quot;center&quot; valign=&quot;middle&quot;> <div align=&quot;center&quot;> 
              <%# dsSatisfaction.FieldValue(&quot;sum_QM_Average&quot;, Container) %>
            </div></td>
          <td align=&quot;center&quot; valign=&quot;middle&quot;> <div align=&quot;center&quot;> 
              <%# dsSatisfaction.FieldValue(&quot;sum_QM_Cost_Average&quot;, Container) %>
            </div></td>
        </tr>
      </ItemTemplate>
	  <alternatingitemtemplate>
        <tr> 
          <td bgcolor=&quot;#DDDDDD&quot; nowrap><a href=&quot;srcfirm_detail.asp?FirmID=<%# dsSatisfaction.FieldValue(&quot;Member_Received&quot;, Container) %>&quot;> <%# dsSatisfaction.FieldValue(&quot;Member_Recd::Firm_40_char_long&quot;, Container) %></a>
            <br> <%# dsSatisfaction.FieldValue(&quot;Member_Recd::City_for_Web_Site&quot;, Container) %>
            , <%# dsSatisfaction.FieldValue(&quot;Member_Recd::STATE&quot;, Container) %> <%# dsSatisfaction.FieldValue(&quot;Member_Recd::Country&quot;, Container) %> </td>
          <td bgcolor=&quot;#DDDDDD&quot; align=&quot;center&quot; valign=&quot;middle&quot;> <div align=&quot;center&quot;> 
              <%# dsSatisfaction.FieldValue(&quot;Received_count&quot;, Container) %>
            </div></td>
          <td bgcolor=&quot;#DDDDDD&quot; align=&quot;center&quot; valign=&quot;middle&quot;> <div align=&quot;center&quot;> 
              <%# dsSatisfaction.FieldValue(&quot;sum_QM_Average&quot;, Container) %>
            </div></td>
          <td bgcolor=&quot;#DDDDDD&quot; align=&quot;center&quot; valign=&quot;middle&quot;> <div align=&quot;center&quot;> 
              <%# dsSatisfaction.FieldValue(&quot;sum_QM_Cost_Average&quot;, Container) %>
            </div></td>
        </tr>
      </alternatingitemtemplate>
<FooterTemplate>
  </table>
  </FooterTemplate>
    </ASP:Repeater>
</form>

<MM:If runat=&quot;server&quot; Expression='<%# (dsSatisfaction.RecordCount = 0) %>'>
  <ContentsTemplate>no records returned...</ContentsTemplate>
</MM:If>
<MM:If runat=&quot;server&quot; Expression='<%# (dsSatisfaction.CurrentPage <> 0) %>'>
  <ContentsTemplate><a href=&quot;<%# Request.ServerVariables(&quot;SCRIPT_NAME&quot;) %>?dsSatisfaction_currentPage=<%# dsSatisfaction.CurrentPage - 1 %>&quot;><<Previous</a></ContentsTemplate>
</MM:If>
    
<MM:If runat=&quot;server&quot; Expression='<%# (dsSatisfaction.CurrentPage < dsSatisfaction.LastPage) %>'>
  <ContentsTemplate><a href=&quot;<%# Request.ServerVariables(&quot;SCRIPT_NAME&quot;) %>?dsSatisfaction_currentPage=<%# dsSatisfaction.CurrentPage + 1 %>&quot;>Next>></a></ContentsTemplate>
</MM:If>
<br>
<br>
<b>Total record count:</b>  <%= dsSatisfaction.RecordCount %>
</body>
</html>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top