![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I want to add a simple message to display if no records are found in a search query. How could I append the following code to display a message "No records found"? % Dim Recordset1__MMColParam Recordset1__MMColParam = "1" If (Request.Form("txtKeywords") <> "") Then Recordset1__MMColParam = Request.Form("txtKeywords") End If % % Dim Recordset1 Dim Recordset1_numRows Set Recordset1 = Server.CreateObject("ADODB.Recordset") Recordset1.ActiveConnection = MM_DBConn_STRING strTest = Request.Form("selMatchType") Select Case strTest Case "Exact" Recordset1.Source = "SELECT * FROM tblProducts WHERE prod_number = '" + Replace(Recordset1__MMColParam, "'", "''") + "'" Case "Ending" Recordset1.Source = "SELECT * FROM tblProducts WHERE prod_number LIKE '%" + Replace(Recordset1__MMColParam, "'", "''") + "'" Case "Contain" Recordset1.Source = "SELECT * FROM tblProducts WHERE prod_number LIKE '%" + Replace(Recordset1__MMColParam, "'", "''") + "%'" Case "Begin" Recordset1.Source = "SELECT * FROM tblProducts WHERE prod_number LIKE '" + Replace(Recordset1__MMColParam, "'", "''") + "%'" End Select Recordset1.CursorType = 0 Recordset1.CursorLocation = 2 Recordset1.LockType = 1 Recordset1.Open() Recordset1_numRows = 0 % I was trying to include another case where the Recordset1.Source came up empty or something like that. Case Else Recordset1.Source = "" Response.Write("No records found.") But that doesn't work. Any help is appreciated. Thanks. -D- |
#3
| |||
| |||
|
|
D, presumably things like Case "" doesn't work, or perhaps NULL, or simply else? Anyways, by far the simplest way (simple is best) would be to simply write your message onto the page and enclose it in a 'Show Region if RS Empty' server behaviour. Craig "-D-" <noone (AT) nospam (DOT) com> wrote in message news:cdev50$gnd$1 (AT) forums (DOT) macromedia.com... I want to add a simple message to display if no records are found in a search query. How could I append the following code to display a message "No records found"? % Dim Recordset1__MMColParam Recordset1__MMColParam = "1" If (Request.Form("txtKeywords") <> "") Then Recordset1__MMColParam = Request.Form("txtKeywords") End If % % Dim Recordset1 Dim Recordset1_numRows Set Recordset1 = Server.CreateObject("ADODB.Recordset") Recordset1.ActiveConnection = MM_DBConn_STRING strTest = Request.Form("selMatchType") Select Case strTest Case "Exact" Recordset1.Source = "SELECT * FROM tblProducts WHERE prod_number = '" + Replace(Recordset1__MMColParam, "'", "''") + "'" Case "Ending" Recordset1.Source = "SELECT * FROM tblProducts WHERE prod_number LIKE '%" + Replace(Recordset1__MMColParam, "'", "''") + "'" Case "Contain" Recordset1.Source = "SELECT * FROM tblProducts WHERE prod_number LIKE '%" + Replace(Recordset1__MMColParam, "'", "''") + "%'" Case "Begin" Recordset1.Source = "SELECT * FROM tblProducts WHERE prod_number LIKE '" + Replace(Recordset1__MMColParam, "'", "''") + "%'" End Select Recordset1.CursorType = 0 Recordset1.CursorLocation = 2 Recordset1.LockType = 1 Recordset1.Open() Recordset1_numRows = 0 % I was trying to include another case where the Recordset1.Source came up empty or something like that. Case Else Recordset1.Source = "" Response.Write("No records found.") But that doesn't work. Any help is appreciated. Thanks. -D- |
#4
| |||
| |||
|
|
Craig, Is there an extension for the "Show Region if RS Empty" server behavior? If so, where can I download it? Thanks for your help. -D- "Craig" <csintheuk (AT) hotmail (DOT) com> wrote in message news:cdfhbf$5fp$1 (AT) forums (DOT) macromedia.com... D, presumably things like Case "" doesn't work, or perhaps NULL, or simply else? Anyways, by far the simplest way (simple is best) would be to simply write your message onto the page and enclose it in a 'Show Region if RS Empty' server behaviour. Craig "-D-" <noone (AT) nospam (DOT) com> wrote in message news:cdev50$gnd$1 (AT) forums (DOT) macromedia.com... I want to add a simple message to display if no records are found in a search query. How could I append the following code to display a message "No records found"? % Dim Recordset1__MMColParam Recordset1__MMColParam = "1" If (Request.Form("txtKeywords") <> "") Then Recordset1__MMColParam = Request.Form("txtKeywords") End If % % Dim Recordset1 Dim Recordset1_numRows Set Recordset1 = Server.CreateObject("ADODB.Recordset") Recordset1.ActiveConnection = MM_DBConn_STRING strTest = Request.Form("selMatchType") Select Case strTest Case "Exact" Recordset1.Source = "SELECT * FROM tblProducts WHERE prod_number = '" + Replace(Recordset1__MMColParam, "'", "''") + "'" Case "Ending" Recordset1.Source = "SELECT * FROM tblProducts WHERE prod_number LIKE '%" + Replace(Recordset1__MMColParam, "'", "''") + "'" Case "Contain" Recordset1.Source = "SELECT * FROM tblProducts WHERE prod_number LIKE '%" + Replace(Recordset1__MMColParam, "'", "''") + "%'" Case "Begin" Recordset1.Source = "SELECT * FROM tblProducts WHERE prod_number LIKE '" + Replace(Recordset1__MMColParam, "'", "''") + "%'" End Select Recordset1.CursorType = 0 Recordset1.CursorLocation = 2 Recordset1.LockType = 1 Recordset1.Open() Recordset1_numRows = 0 % I was trying to include another case where the Recordset1.Source came up empty or something like that. Case Else Recordset1.Source = "" Response.Write("No records found.") But that doesn't work. Any help is appreciated. Thanks. -D- |
![]() |
| Thread Tools | |
| Display Modes | |
| |