关于asp中的数据库连接问题
我写了一个表单就是用来向数据库中添加数据的 action=post.asp method=post
然后再post.asp当中我又通过request.form获取了相应的值,然后添加的数据库当中
所有的代码如下
------------------------------------conn.asp-----------------------------
<%
dim db
const databasetype="access"
db="data\meiyijixie.mdb"
dim connstr
dim conn
ConnStr ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(db)
set conn=server.createobject("ADODB.Connection")
conn.open connstr
'sub CloseConn()
' On Error Resume Next
' If IsObject(Conn) Then
' conn.close
' set conn=nothing
' end if
'end sub
%>
------------------------------------post.asp------------------------------------------
<!--#include file=conn.asp-->
<%
dim name,tel,email,content
name=request.form("name")
email=request.form("email")
tel=request.form("tel")
content=request.form("content")
qq=request.form("qq")
if request.form("name")="" then
response.write"<script language='javascript'> alert('姓名不可以为空!');history.back('zxly.asp');</script>"
response.end
end if
if content="" then
response.write"<script language='javascript'>alert('留言内容不能为空!');history.back('zxly.asp');</script>"
response.end
end if
if tel="" then
response.write"<script language='javascript'>alert('请留下你的联系方式!');history.back('zxly.asp');</script>"
end if
if email="" then
response.write"<script language='javascript'> alert('请留下你的联系方式!');history.back('zxly.asp');"
end if
%>
<%
set rs=server.createobject("ADODB.RecordSet")
sql="select *from liuyan where id is null"
rs.open sql,conn,1,3
rs.addnew
rs("name")=name
rs("tel")=tel
rs("email")=email
rs("content")=content
rs.update
rs.close
set rs=nothing
response.write "<script language='javascript'>alert('留言提交成功');history.back('index.asp')</script>"
response.end
%>
然后出现的结果是:
Couldn't load file: F:\cs
相关文档:
最近做一个用asp做的网站后台的数据导出功能时,google,baidu了很多,但是多数都是转载,代码大概都一样,但是就是报错,最后有人说通过设置MIME类型和建立模板,最后整理,测试问题终于解决.关键的地方有以下几点:
1):MIME类型要设置正确,如要把DB中表(或表中指定字段)的数据导出成exel格式时,头部的MEMI类型的设置是:
<%
......
asp导出EXCEL数字格式及自动适应宽度的问题
下面直接进行代码演示:
<%
If Response.IsClientConnected Then
Response.Flush
Else
Response.End
End If
Set xlApplication = Server.CreateObject("Excel.Application")
xlApplication.Visible = False
xlApplication.Workbooks.Add
Set xlWorksheet = xl ......
内容是:
function _doPostBack(){};
if(typeof("__doPostBack")=="function")
{
_doPostBack=__doPostBack;
__doPostBack=_doPostBackNew;
}
document.attachEvent("onmousemove",_onmousemove);
var _isPosting=false;
var _divMask=null; ......
public static void SetTreeNode(System.Web.UI.WebControls.TreeView treeRolePopedom, string rolecode,out string errMsg)
{
int k = 0;
& ......
在 ASP .NET 的 AJAX 控件中 TabContainer 的 CSS 样式的编写具有一定的格式规范及命名规则,如下图:
具体的 CSS 样式的编写为:
.ajax_tab_menu .ajax__tab_header /*整体按钮底样式*/
{
font-family:宋体;
height:29px;
font-size:12px;
background:#181c1f repeat-x bottom;
}
.ajax_tab_menu .ajax__tab ......