推奨:ADO初心者のチュートリアル:ADOディスプレイレコードセットからデータを表示する最も一般的な方法は、HTMLテーブルにデータを表示することです。フィールド名とフィールド値を表示NorthWindという名前のデータベースがあり、顧客テーブルにデータを表示します(拡張機能として.aspでこのファイルを保存することを忘れないでください):htmlbody%set conn = server.createobject(
ユーザーログイン検証スクリプト、chkpwd.asp
- <%
- '========ユーザーログイン検証スクリプト========
- '通過したオブジェクトが定義されていない場合、それは偽として定義され、検証に合格していないことを示します
- ifisempty(セッション(合格))その後
- セッション(合格)= false
- endif
- 'セッション(合格)= false。つまり、フォームから渡された検証情報はまだ渡されていません。
- ifsession(合格)= falsethen
- username = request.form(username)
- userpwd = request.form(userpwd)
- ifusername = then
- errmsg =ヒント:ユーザー名とパスワードを入力してください
- それ以外
- '============================================================
- setConn = server.createObject(adodb.Connection)
- conn.connectionString = driver = {sqlserver}; server = 192.168.1.3; uid = sa; pwd =; database = zcmrs
- conn.open
- '=================================テーブルログからユーザーデータをお読みください=========================
- 'レコードセットオブジェクトを定義します
- setrs = server.createObject(adodb.Recordset)
- '接続オブジェクトの接続ストリングを設定します
- setrs.activeconnection = conn
- 'カーソルタイプを設定します
- rs.cursortype = 3
- 'オープンレコードセット
- rs.openselectusername、passwordfromerpuserwhereusername = '&username&'
- '============================================================
- ifrs.eoftthen
- errmsg =ヒント:ユーザーが存在しないか、パスワードが間違っています
- それ以外
- ifuserpwd <> rs.fields(パスワード)
- errmsg = tip:ログインに失敗しました!パスワードエラー?
- else'loginに成功しました
- errmsg =
- セッション(合格)= true
- session(username)= rs.fields(username)
- 'ユーザー許可セッション(userid)= rs.fields(userid)を識別する
- endif
- endif
- endif
- endif
- 'ログインに障害が発生した後、ログインフォームが描画されます
- ifnotsession(合格)= truethen
- %>
- <html>
- <head> <title> design home_dwww.cn </title>
- <styletype = text/css>
- <! -
- .style1 {font-size:12px; font-weight:bold; margin-left:120px; outline:double}
- - >
- </style>
- <styletype = text/css>
- <! -
- .style2 {font-size:12px; font-weight:bold; outline:double; color:#ff3333}
- - >
- </style>
- </head>
- <bodyleftmargin = 0topmargin = 0marginheight = 0marginwidth = 0bgcolor =#000000>
- <divid = parentStyle = height:300; width:450; border-style:solid; border-color:#fffff; margin-top:80px; margin-left:25%; margin-right:25%; background-color:#fffff>
- <divid = denglustyle = font-size:12px; font-weight:boland; background-color:#0099ff; text-align:center; height:40px;> <br> erpシステムログイン</div>
- <formaction = <%= request.servervariables(path_info)%> method = postname = myformid = myform>
- <pclass = style1> username:<inputname = usernametype = textId = usernamesize = 18maxlength = 20>
- </p>
- <pclass = style1>パスワード:<inputname = userpwdtype = passwordId = userpwdsize = 18maxlength = 20>
- </p>
- <palign = centerclass = style2> <%= errmsg%> </p>
- <p>
- <inputtype = submitalign = middlename = submitvalue = login system>
- <inputname = regetype = buttonAlign = midderonclick = location = 'register.asp'id = regevalue = register user>
- </p>
- </form>
- </div>
- </body>
- </html>
- <%
- '<pclass = style1>検証コード:<inputname = checkcodetype = textId = checkcodesize = 6maxlength = 4>
- '<imgstyle = margin-right:40pxalt = src = common/getcode.asp> </p>
- Response.End
- endif
- %>
erp.aspにアクセスするページ
- <! - #includefile = chkpwd.asp>
- <body>
- <divStyle = 'font-size:12px; font-weight:bold; border:1pxsolid#001; padding:4px; background:#ffcfff; margin-top:0;'> ERPクエリシステムを使用するように、現在のログインユーザーは次のとおりです。
- <%
- ifsession(合格)= truethen
- Response.write(session(username)))
- endif
- %> <ahref = logout.asp>システムを終了</a>
- </div>
- </body>
erp.aspを開くたびに、最初にchkpwd.asp()を実行します。これにより、不正なユーザーが指定されたWebページにアクセスできないようにします。
logout.aspシステム終了
- <body>
- <%
- セッション(合格)= false
- セッション(username)=
- Response.redirect(index.asp)
- %>
- </body>
写真を使用してフォームを送信します
- <formName = form1method = postaction =>
- <tdalign = right> <inputtype = imagemethod = submitname = submitsrc = image/loginin.gifwidth = 70height = 21alt = submit> </td>
- </form>
共有:ADO初心者のチュートリアル:ADO RECORDSを追加しますSQLの挿入を使用してコマンドに挿入して、データベース内のテーブルにレコードを追加できます。データベースにテーブルにレコードを追加すると、NorthWindデータベースの顧客テーブルに新しいレコードを追加する必要があります。最初に、データを選択するフィールドを含むフォームを作成する必要があります:htmlbodyform method = post action = dem