Visual Basic, .NET, ASP, VBScript
 

   
   
     

Форум - Общий форум

Страница: 1 |

 

  Вопрос: Организация поиска по БД ACCESS в ASP..... Добавлено: 16.01.03 13:07  

Автор вопроса:  STEAM | ICQ: 276847102 

Может кто подскажет или есть примерчик простенький на JAVASCRIPT  или VBSCRIPT... В принципе ничего сложного там нет ... дошел до request.querystring(""), но как заставить обращаться к нему не очень то понимаю... Плиз помогите новичку

 

Ответить

  Ответы Всего ответов: 1  

Номер ответа: 1
Автор ответа:
 dba_netanya



Вопросов: 8
Ответов: 24
 Web-сайт: www.jnews.com
 Профиль | | #1
Добавлено: 16.01.03 20:30

The example from my page for getting records.

<html>
<head>
 <style>
 td { font-size : 9pt; font-family : Verdana, Arial; text-decoration : none; }
 body { font-size : 9pt; font-family : Verdana, Arial; text-decoration : none; }
 input   { font-size : 9pt; font-family : Verdana, Arial; height : 17; }
 </style>
</head>
<body background=img/dot.gif>
<%@ CODEPAGE = 1251%>

<%
Sub AskForNumber()
  Response.Write ("Last records:<HR>")
  Response.Write ("<FORM ACTION = date_records.asp?mode=search METHOD = POST>")
  Response.Write ("Please, enter date: ")
  Response.Write ("<INPUT TYPE = TEXT NAME = txtDate>")
  Response.Write ("<INPUT TYPE = SUBMIT VALUE = ""Find"">")
  Response.Write ("</FORM>")
End Sub

Sub GetRecordsList()
  ;Dim cn, rs, SearchString
  
  SearchString = Request.Form ("txtDate")
    
  If SearchString = "" Then
    Response.Redirect "date_records.asp"
  End If  
  
  Set cn = Server.CreateObject ("ADODB.Connection")
  data_source = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _
            Server.MapPath("db\find.mdb")
     cn.Open data_source
     
     sSQL = "SELECT * FROM find WHERE date_record > #" & SearchString & "# ORDER BY ID"
     
     Set rs = cn.Execute (sSQL)

  
   Response.Write ("<FORM ACTION = date_records.asp?mode=ask METHOD = POST>")
   Response.Write ("<TABLE BORDER=1><TR> ::Last records:: </TR><BR>")
   Response.Write ("<TR><TH>ID<TH>")
   Response.Write ("<TH>Name<TH>")
   Response.Write ("<TH>Place<TH>")
   Response.Write ("<TH>Birthday<TH>")
   Response.Write ("<TH>;Date of aliya<TH>")
   Response.Write ("<TH>Last address<TH>")
   Response.Write ("<TH>Reason<TH>")
    While Not rs.EOF
      Response.Write ("<TR><TD>")
      Response.Write rs.Fields ("id")
      Response.Write ("<TD><TD>")
      Response.Write rs.Fields ("name")
      Response.Write ("<TD><TD>")
      Response.Write rs.Fields ("born")
      Response.Write ("<TD><TD>")
      Response.Write rs.Fields ("data")
      Response.Write ("<TD><TD>")
      Response.Write rs.Fields ("data_rep")
      Response.Write ("<TD><TD>")
      Response.Write rs.Fields ("address")
      Response.Write ("<TD><TD>")
      Response.Write rs.Fields ("prichina")
      Response.Write ("<TD><TR>")      
     rs.MoveNext
    Wend
   Response.Write ("<INPUT TYPE = SUBMIT VALUE = ""Ask"">")
   
   Response.Write ("</FORM>")   
 
  Response.Write ("Delete blank records:<HR>")
  Response.Write ("<FORM ACTION = date_records.asp?mode=delete METHOD = POST>")
  Response.Write ("<INPUT TYPE = SUBMIT VALUE = ""Delete"">")
  Response.Write ("</FORM>")
  
  Response.Write ("Delete record number: ")
  Response.Write ("<FORM action = date_records.asp?mode=delnum method=post>")
  Response.Write ("<INPUT TYPE = TEXT NAME = txtDELNUM>")
  'Response.Write ("<INPUT TYPE = HIDDEN NAME = "mode" VALUE = "search">")
  Response.Write ("<INPUT TYPE = SUBMIT VALUE = ""DelNumber"">")
  Response.Write ("</FORM>")
  
  rs.Close
  cn.Close
 Set rs = Nothing
 Set cn = Nothing  
 
End Sub

Sub DeleteBlankRecords()
 ;Dim cn, rs
 Set cn = Server.CreateObject("ADODB.Connection")
 data_source = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _
            Server.MapPath("db\find.mdb")
    cn.Open data_source
   
    sSQL = "DELETE * FROM find WHERE name = ''"
   
    Set rs = cn.Execute (sSQL)
   
    'rs.Open
    'rs.Save "C:\rs.txt"
   
    GetRecordsList
End Sub

Sub DeleteRecordNumber()
 ;Dim cn, rs, RecNumber
 
 RecNumber = Request.Form ("txtDELNUM")
 
 If RecNumber = "" Then
  Response.Redirect "date_records.asp?mode=search"
  'Exit Sub
 End If
 
 Set cn = Server.CreateObject ("ADODB.Connection")
 Set rs = Server.CreateObject ("ADODB.RecordSet")
 
 
 data_source = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _
            Server.MapPath("db\find.mdb")
    cn.Open data_source
   
    sSQL = "DELETE * FROM find WHERE id = " & RecNumber
   
    Set rs = cn.Execute (sSQL)
    GetRecordsList
End Sub

Select Case Request.QueryString ("mode")
  Case "search"
    GetRecordsLIst
  Case "delete"
    ;DeleteBlankRecords
  Case "delnum"
    ;DeleteRecordNumber
  Case Else
    AskForNumber
End Select

%>
</TABLE>
</BODY>
</HTML>

...but I am beginning in ASP.

Ответить

Страница: 1 |

Поиск по форуму



© Copyright 2002-2011 VBNet.RU | Пишите нам