ASP操作SQLite数据库

asp

2009-09-07 14:05

要用ASP来操作SQLite数据库,前提条件是在服务器上得安装SQLite的ODBC驱动程序,可到这个站点上下载安装:http://www.ch-werner.de/sqliteodbc/,安装好后就可以像使用Access一样来使用SQLite了!下边是一个SQLite数据库结构:

引用内容 引用内容 Create TABLE admin(username text,age integer);
我们再来用ASP演示下如何对SQLite数据库进行记录的增、查、改、删操作:

程序代码 程序代码 <%
Response.Buffer = False '不加此句可能出现"超过响应缓冲区限制"错误
Set conn = Server.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.RecordSet")
conn.open "DRIVER={SQLite3 ODBC Driver};Database=F:\mzwucom\bbs\db1.db"
conn.execute("insert into admin values('usera',20)")
'conn.execute("update admin set username='kk' where username='usera'")
'conn.execute("delete from admin where age=20")
rs.open "select * from admin",conn,1,1
Do while Not rs.Eof
     Response.Write(rs("username") & "," & rs("age") & "<br/>")
     rs.movenext
Loop
rs.close
Set rs = Nothing
conn.close
Set conn = Nothing
%>
摘自木子屋http://www.mzwu.com/article.asp?id=1405