Skip to main content
Participant
September 22, 2006
Question

Using Operator Field in ASP.NET Search Form

  • September 22, 2006
  • 1 reply
  • 211 views
I am trying to create a search form in Dreamweaver 8 using VB ASP.NET. What I would like to do is to have the user choose the comparison operator (=,>,etc.). by choosing it in a field. Does anyone have an example of this in a dataset?

Here is what I have so far for the dataset:

<MM:DataSet
id="rs_SystemParts"
runat="Server"
IsStoredProcedure="false"
ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_STRING_NetworkAssets") %>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_DATABASETYPE_NetworkAssets") %>'
CommandText='<%# "SELECT * FROM dbo.NAT_SYSTEM WHERE ""Parameter"" = @Parameter AND ""Value" = @778398" %>'
Debug="true"
>
<Parameters>
<Parameter Name="@Parameter" Value='<%# IIf((Request.Form("ParameterList") <> Nothing), Request.Form("ParameterList"), "") %>' Type="VarChar" />
<Parameter Name="@Value" Value='<%# IIf((Request.Form("Value") <> Nothing), Request.Form("Value"), "") %>' Type="VarChar" />
</Parameters>
</MM:DataSet>
This topic has been closed for replies.

1 reply

Inspiring
September 25, 2006
The standard MM dataset is too restricitve to allow for that type of
operation. The following code uses the MM connector but a hand written SQL
statement to then bind to a datagrid.

<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1"
%>
<%@ Import NameSpace="System.Data.OleDB"%>
<script runat="server">
Sub Page_Load()
If Not Page.IsPostBack then
getDetails()
End if
End Sub

Sub getDetails()
Dim strSQL as String
strSQL = "SELECT * FROM dbo.NAT_SYSTEM WHERE FIELDA " &
request.Form("Parameter") & " " & request.Form("value")
Dim objConn As New
OleDbConnection(ConfigurationSettings.AppSettings("MM_CONNECTION_STRING_dbDebtors"))

Dim objCmd As New OleDbCommand(strSQL, objConn)
objConn.Open()
Dim objRdr As OleDbDataReader = objCmd.ExecuteReader()
DataGrid1.DataSource = objRdr
DataGrid1.DataBind()
objRdr.Close()
objConn.Close()
End Sub
</script>

--
Paul Whitham
Certified Dreamweaver MX2004 Professional
Adobe Community Expert - Dreamweaver

Valleybiz Internet Design
www.valleybiz.net

"pwochnick" <webforumsuser@macromedia.com> wrote in message
news:ef1omo$oql$1@forums.macromedia.com...
>I am trying to create a search from in Dreamweaver 8 using VB ASP.NET. What
>I
> would like to do is to have the user choose the comparison operator
> (=,>,etc.).
> by choosing it in a field. Does anyone have an example of this in a
> dataset?
>
> Here is what I have so far for the dataset:
>
> <MM:DataSet
> id="rs_SystemParts"
> runat="Server"
> IsStoredProcedure="false"
> ConnectionString='<%#
> System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_STRING_Net
> workAssets") %>'
> DatabaseType='<%#
> System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_DATABASETY
> PE_NetworkAssets") %>'
> CommandText='<%# "SELECT * FROM dbo.NAT_SYSTEM WHERE ""Parameter"" =
> @Parameter AND ""Value" = @Value" %>'
> Debug="true"
> >
> <Parameters>
> <Parameter Name="@Parameter" Value='<%#
> IIf((Request.Form("ParameterList") <> Nothing),
> Request.Form("ParameterList"),
> "") %>' Type="VarChar" />
> <Parameter Name="@Value" Value='<%# IIf((Request.Form("Value") <>
> Nothing), Request.Form("Value"), "") %>' Type="VarChar" />
> </Parameters>
> </MM:DataSet>
>