关于VBScript语言,用文本框查询数据库的问题。
文本域的信息:<inputname="UserID"type="text"id="UserID"/>按钮信息:<inputtype="submit"name="Submi...
文本域的信息:<input name="UserID" type="text" id="UserID" />
按钮信息:<input type="submit" name="Submit" value="查询" />
当在文本域中输入数据的时候,单击按钮,那么文本域中的数据与数据库中的数据先匹配,则显示出。如何写这段if代码。
以下是我的错误代码,求怎么改?
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="Connections/ebook.asp" -->
<%
Str=""
UesrID=Trim(Request.Form("UserID"))
If UserID <> "" Then
StrSql = "UserID"
End If
%>
<%
Dim Rs1
Dim Rs1_numRows
Set Rs1 = Server.CreateObject("ADODB.Recordset")
Rs1.ActiveConnection = MM_ebook_STRING
if Trim(Str)<>""then
Rs1.Source = "SELECT * FROM ShopBook where"&Str
else
Rs1.Source = "SELECT * FROM ShopBook"
Rs1.CursorType = 0
Rs1.CursorLocation = 2
Rs1.LockType = 1
Rs1.Open()
Rs1_numRows = 0
end if
%> 展开
按钮信息:<input type="submit" name="Submit" value="查询" />
当在文本域中输入数据的时候,单击按钮,那么文本域中的数据与数据库中的数据先匹配,则显示出。如何写这段if代码。
以下是我的错误代码,求怎么改?
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="Connections/ebook.asp" -->
<%
Str=""
UesrID=Trim(Request.Form("UserID"))
If UserID <> "" Then
StrSql = "UserID"
End If
%>
<%
Dim Rs1
Dim Rs1_numRows
Set Rs1 = Server.CreateObject("ADODB.Recordset")
Rs1.ActiveConnection = MM_ebook_STRING
if Trim(Str)<>""then
Rs1.Source = "SELECT * FROM ShopBook where"&Str
else
Rs1.Source = "SELECT * FROM ShopBook"
Rs1.CursorType = 0
Rs1.CursorLocation = 2
Rs1.LockType = 1
Rs1.Open()
Rs1_numRows = 0
end if
%> 展开
展开全部
我要改的话;
Str=""
if Request.Form("UserID")<>"" then
xxxxx=Request.Form("UserID")
Str = " where id="&xxxxxx
End If
%>
<%
Dim Rs1
Dim Rs1_numRows
Set Rs1 = Server.CreateObject("ADODB.Recordset")
Rs1.ActiveConnection = MM_ebook_STRING
Rs1.Source = "SELECT * FROM ShopBook "&Str
Rs1.CursorType = 0
Rs1.CursorLocation = 2
Rs1.LockType = 1
Rs1.Open()
Rs1_numRows = 0
end if
表单里面是数字,如果是字符 Str = " where 用户名=' "&xxxxxx&" ' "
Str=""
if Request.Form("UserID")<>"" then
xxxxx=Request.Form("UserID")
Str = " where id="&xxxxxx
End If
%>
<%
Dim Rs1
Dim Rs1_numRows
Set Rs1 = Server.CreateObject("ADODB.Recordset")
Rs1.ActiveConnection = MM_ebook_STRING
Rs1.Source = "SELECT * FROM ShopBook "&Str
Rs1.CursorType = 0
Rs1.CursorLocation = 2
Rs1.LockType = 1
Rs1.Open()
Rs1_numRows = 0
end if
表单里面是数字,如果是字符 Str = " where 用户名=' "&xxxxxx&" ' "
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询