using System; using System.Collections.Generic; using System.Linq; using System.Text; // using System.Data.SqlClient; using System.Data; using Model;namespace DAL { public class BookDAO { DBConn db = new DBConn(); public DataSet GetData(string sSql) { SqlConnection conn = db.GetConn(); try { conn = db.GetConn(); SqlDataAdapter da = new SqlDataAdapter(sSql, conn); DataSet ds = new DataSet(); da.Fill(ds); return ds; } catch (Exception) { throw; } finally { conn.Close(); } } //获取所有图书信息 public DataSet GetBook() { string sSql = string.Format("SELECT * FROM Book"); return GetData(sSql); } //查询图书 public DataSet FindBook(Book book) { string sSql = string.Format("SELECT * FROM Book WHERE Bookname like '%" + book.Bookname + "%'"); string result = db.RunSqlReturn(sSql); if (result == "") { return GetBook(); } else { return GetData(sSql); } } 希望对你有帮助,在UI层把DataGridview绑定到Dataset
再改一下<% dim nameKey nameKey=Trim(Request.QueryString("name"))connstr="DBQ="+server.mappath("database.mdb")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};" set conn=server.createobject("ADODB.CONNECTION") conn.open connstrif nameKey<>"" then sql="SELECT * FROM student WHERE studentName like '%" + nameKey + "%'" else sql="select * from student" end if set rs=conn.execute(sql) while not rs.eof response.Write(rs("name")) rs.movenext wend %>
using System.Collections.Generic;
using System.Linq;
using System.Text;
//
using System.Data.SqlClient;
using System.Data;
using Model;namespace DAL
{
public class BookDAO
{
DBConn db = new DBConn();
public DataSet GetData(string sSql)
{
SqlConnection conn = db.GetConn();
try
{
conn = db.GetConn();
SqlDataAdapter da = new SqlDataAdapter(sSql, conn);
DataSet ds = new DataSet();
da.Fill(ds);
return ds;
}
catch (Exception)
{
throw;
}
finally
{
conn.Close();
} }
//获取所有图书信息
public DataSet GetBook()
{
string sSql = string.Format("SELECT * FROM Book");
return GetData(sSql);
} //查询图书
public DataSet FindBook(Book book)
{
string sSql = string.Format("SELECT * FROM Book WHERE Bookname like '%" + book.Bookname + "%'");
string result = db.RunSqlReturn(sSql);
if (result == "")
{
return GetBook();
}
else
{
return GetData(sSql);
}
}
希望对你有帮助,在UI层把DataGridview绑定到Dataset
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head><body>
<div>
<form id="form1" name="form1" method="post" action="">
姓名
<input name="name" type="text" id="name" />
<br />
<input type="submit" name="Submit" value="搜索" />
</form>
</div>
<%
dim nameKey
nameKey=Trim(Request.QueryString("name"))if nameKey<>"" then
connstr="DBQ="+server.mappath("database.mdb")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
set conn=server.createobject("ADODB.CONNECTION")
conn.open connstrsql="SELECT * FROM student WHERE studentName like '%" + nameKey + "%'"
set rs=conn.execute(sql)
while not rs.eof
response.Write(rs("name"))
wend
rs.movenext
end if%>
</body>
</html>
上面这段代码应该改成这样
<form id="form1" name="form1" method="get" action="">楼主可不可以推荐一部看过的觉得还不错的asp.net(C#)的教程呀?最好网上能有pdf文档的
dim nameKey
nameKey=Trim(Request.QueryString("name"))connstr="DBQ="+server.mappath("database.mdb")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
set conn=server.createobject("ADODB.CONNECTION")
conn.open connstrif nameKey<>"" then
sql="SELECT * FROM student WHERE studentName like '%" + nameKey + "%'"
else
sql="select * from student"
end if
set rs=conn.execute(sql)
while not rs.eof
response.Write(rs("name"))
rs.movenext
wend
%>
分页一行代码都可以不写。
楼主百度一下下载地址,或者
http://www.pwmis.com/sqlmap