<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<script language="vb" runat="server" Debug=true>
Sub chaxun(Src As Object, E As EventArgs)
Dim conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Inetpub\wwwroot\asp.net\login.mdb")
Dim cmd As New OleDbCommand("select meaning from log where word like '"+ word.text +"'",conn)
conn.Open()
Dim dr As OleDbDataReader=cmd.ExecuteReader()
if dr.Read()=True then
message.text = dr.Item("meaning")
else
message.text="没有您查询的单词!"
end if
End Sub
</script>
<html>
<head>
<title>数据库查询</title>
</head>
<body>
<h1 align="center">单词查询</h1>
<form runat="server">
请输入您要查询的单词 :
<asp:TextBox ID="word" MaxLength="20" TextMode="SingleLine" runat="server" />
<asp:Button ID="search" Text="查询" OnClick="chaxun" runat="server" /><br>
<asp:Label ID="message" runat="server"/>
</form>
</body>
</html>
错误如下:
不能使用 '';文件已在使用中。
<%@ Import Namespace="System.Data.OleDb" %>
<script language="vb" runat="server" Debug=true>
Sub chaxun(Src As Object, E As EventArgs)
Dim conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Inetpub\wwwroot\asp.net\login.mdb")
Dim cmd As New OleDbCommand("select meaning from log where word like '"+ word.text +"'",conn)
conn.Open()
Dim dr As OleDbDataReader=cmd.ExecuteReader()
if dr.Read()=True then
message.text = dr.Item("meaning")
else
message.text="没有您查询的单词!"
end if
End Sub
</script>
<html>
<head>
<title>数据库查询</title>
</head>
<body>
<h1 align="center">单词查询</h1>
<form runat="server">
请输入您要查询的单词 :
<asp:TextBox ID="word" MaxLength="20" TextMode="SingleLine" runat="server" />
<asp:Button ID="search" Text="查询" OnClick="chaxun" runat="server" /><br>
<asp:Label ID="message" runat="server"/>
</form>
</body>
</html>
错误如下:
不能使用 '';文件已在使用中。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货