Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Using Operator Field in ASP.NET Search Form

New Here ,
Sep 22, 2006 Sep 22, 2006
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" = @Deleted User" %>'
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>
TOPICS
Server side applications
210
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 24, 2006 Sep 24, 2006
LATEST
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>
>


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines