<body>
<%
Dim a
Dim b
Dim con
Dim rs
Dim res
Dim t
a=request.form("username")
b=request.form("password")
//1.创建数据库连接
Set con=Server.CreateObject("ADODB.Connection")
con.ConnectionString="Driver={Microsoft Access Driver (*.mdb)};DBQ=E:\\ftp\\ASP\\users.mdb"
con.open
//2.执行数据库操作
//SQL:struction Query Language ----- 任何数据库都支持
t="insert into users values('"+a+"','"+b+"')"
Set rs=con.execute(t)
//3.处理数据库执行结果
%>
</body>
就是 //3.处理数据库执行结果 这一部分..老师说考试要考的,,但是哥们我不会,,,拜托了各位大婶们..别BS我哈
把题目写完整,要实现什么功能,光说一个//3.处理数据库执行结果,不知道怎么帮你
1:数据库连接
<%
SqlLocalName = "(local)"
SqlDatabaseName = "hanchen"
SqlUsername = "sa"
SqlPassword = "123456"
'Dim ConnStr
ConnStr = "Provider = Sqloledb; User ID = " & SqlUsername & "; Password = " & SqlPassword & "; Initial Catalog = " & SqlDatabaseName & "; Data Source = " & SqlLocalName & ";"
On Error Resume Next
Set myconn = Server.CreateObject("ADODB.Connection")
myconn.open ConnStr
If Err Then
err.Clear
Set myconn = Nothing
Response.Write "数据库连接出错,请检查连接字串。"
Response.End
End If
%>
2,数据库操作
########################################################################################################
'添加数据库表数据
########################################################################################################
'方法一
<%
sql="select * from pro"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,2,3
rs.addnew
rs("proid")=trim(request("proid"))
rs.update
set rs=nothing
%>
'方法二
<%
conn.execute("insert into pro values('','**',5,date())")
conn.execute("insert into 目标数据表 select * from 源数据表")
%>
########################################################################################################
'更新、删除数据库表数据
########################################################################################################
<%
conn.execute("update pro set thecheap=" & thecheap & ", ischeap=true where proid='" & proid & "'")
conn.execute("delete from pro where proid='"&proid&"'")
%>
########################################################################################################
'模糊查询SQL语句---应用于ACCESS数据库
########################################################################################################
<% sql="select * from pro where proname like '%" & proname & "%'order by proid desc" %>
<% sql="update QYXM set 字段名=Null where 条件" %>//数字型和字符型更新为空值
<% sql="select * from tablename where 日期字段 between '2005-3-1' and '2005-3-31'"%>//日期字段的查询
<% sql="select * from tablename where convert(char(6),日期字段,112) like '200503'"%>
<% sql="Select * From Tab1 Where [Date]>#2002-1-1#;"%>//access数据库用的是#号不是引号
可能你指的是关闭么?因为不关闭会浪费资源的。那你就写多二行,rs.close Set rs=nothing.
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息