求帮忙找一个asp+asp连接access数据库的网站的后台入口地址

ASP+access数据库地址修改_百度知道
ASP+access数据库地址修改
我有多个ACCESS数据库,请问如何在不修改ASP地址的情况下,任意切换数据库
dim connstr
on error resume next
connstr=&DBQ=&+server.mappath(&data.mdb&)+&;DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};&
DefaultDir=.mdb设置成可定义的变量dm就可以任意切换数据库了dim conn dim connstrConst Sitedm=&quot在后台把
connstr=&DBQ=&+server.mappath(Sitedm)+&;data.mdb&quot
采纳率:72%
来自团队:
为您推荐:
其他类似问题
换一换
回答问题,赢新手礼包
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。ASP连接Access数据库的几种方法
转载 & & 投稿:mdxy-dxy
学习程序很大一部分需要与数据库连接操作,这里简单的整理下asp连接access的一些代码,方便需要的朋友
1. 相对与比较老的环境,建议使用第二个
set dbconnection=Server.CREATEOBJECT("ADODB.CONNECTION")
DBPath = Server.MapPath("customer.mdb")
dbconnection.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & DBPath
SQL="select * from auth where id='" & user_id &"'"
SET uplist=dbconnection.EXECUTE(SQL)
2.win2003以上的机器,建议用此方法,效率更高
set dbconnection=Server.CreateObject("ADODB.Connection")
DBPath = Server.MapPath("customer.mdb")
dbconnection.Open "provider=microsoft.jet.oledb.4.0;data source="&dbpath
SQL="select * from auth where id='" & user_id &"'"
SET uplist=dbconnection.EXECUTE(SQL)
DBPath = Server.MapPath("customer.mdb")
set session("rs")=Server.CreateObject("ADODB.Recordset")
' rs=Server.CreateObject("ADODB.Recordset")
connstr="provider=microsoft.jet.oledb.4.0;data source="&dbpath
SQL="select * from auth where id='" & user_id &"'"
session("rs").Open sql,connstr,1,3
4. 建odbc源xxx
set conn=server.createobject("Adodb.connection")
conn.open "DSN=UID=;PWD=;Database=customer
5、附上一个经常用的sqlserver与access通用的连接数据库代码
Const DataBaseType=1
If DataBaseType=0 then
DBPath="/jb51/news.asp"
SqlNowString = "Now()"
nstr=false
suiji="rnd(id)"
'如果是SQL数据库,请认真修改好以下数据库选项
DataServer = "wwwjb51net" '数据库服务器IP
DataUser = "jb51net" '访问数据库用户名
DataBaseName = "jb51net" '数据库名称
DataBasePsw = "密码" '访问数据库密码
SqlNowString = "getdate()"
suiji="newid()"
On Error Resume Next
If DataBaseType = 1 Then
ConnStr="driver={SQL Server};server="&dataserver&";UID="&datauser&";PWD="&databasepsw&";Database="&databasename
ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(DBPath)
Set conn = Server.CreateObject("ADODB.Connection")
conn.open ConnStr
If Err Then Err.Clear:Set conn = Nothing:Response.Write "数据库连接出错,请检查Conn.asp文件中的数据库参数设置。":Response.End
您可能感兴趣的文章:
大家感兴趣的内容
12345678910
最近更新的内容
常用在线小工具ASP+Access之记录的显示和查询
在输入完记录以后,接下来要做的就是查看存在数据库里的记录和查询的动作了,怎样才能实现这些功能呢?
一般一个查询的动作包括两个网页,搜索页和结果页,搜索页至少包括一个表单,一个表单对象(如文本框)和提交按钮,下面现建立一个搜索页:
然后选中文本框,在下面的属性栏里的文本域中输入该文本框的名称,这个名称同时也起到一个参数的作用,传递给结果页作为查询条件。
选中表单,在下面的属性栏的动作选择结果页的文件,方法选Post,Post和Get方法区别如下:
GET 通过将表单数据作为查询字符串附加到 URL 来发送这些数据。由于 URL 的长度限制为
8192 个字符,因此不要将 GET 方法用于较长的表单。
POST 在消息体中发送表单数据,可传递表单变量。
默认 使用浏览器的默认方法(通常为 GET)。
创建完搜索页,接下来就是创建结果页。在结果页中添加如图记录集,并添加搜索参数,与之前表单中的文本框的名称一致。
然后在结果页中插入动态数据就行了,这里我们插入动态表格,当然也可以在设计完布局后插入动态文本。
测试一下结果如下:
一般模糊语句如下:
SELECT 字段 FROM 表 WHERE 某字段 Like 条件
可在条件前加%,可匹配任意类型和长度的字符,如下图语句:
可以实现对零件号码的模糊查询,测试如下:
可见所有包括m9的零件搜索出来。
已投稿到:
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。Asp+access网上下载的源码,我需要查找关键字功能,求帮忙【asp吧】_百度贴吧
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&签到排名:今日本吧第个签到,本吧因你更精彩,明天继续来努力!
本吧签到人数:0成为超级会员,使用一键签到本月漏签0次!成为超级会员,赠送8张补签卡连续签到:天&&累计签到:天超级会员单次开通12个月以上,赠送连续签到卡3张
关注:29,152贴子:
Asp+access网上下载的源码,我需要查找关键字功能,求帮忙收藏
&%Response.Addheader &Content-Type&,&text/ charset=GB2312&Response.Buffer = TrueResponse.ExpiresAbsolute = Now() - 1Response.Expires = 0Response.CacheControl = &no-cache&'============================Web_MdbUrl=&#sshy_book2013.mdb&'数据库地址Web_SendType=1'为1时留言不需要审核,为0则需要审核Web_WebPass=&admin&'留言密码Web_PageNum=8'每页显示几条留言'============================Pass=request(&Pass&)out=request(&out&)if Pass&&&& thenif Pass&&Web_WebPass thenResponse.Write &密码错误!&elseResponse.Write &登陆成功!&Response.Cookies(&Main_LoginPass&)=Passend ifResponse.Write&&br&&br&&a href='#' onclick=&&AjaxGet('List.asp');return false&&&&& 返回留言列表&/a&&Response.Endend ifMain_LoginPass=Request.Cookies(&Main_LoginPass&)if (Main_LoginPass&&&& and Main_LoginPass&&Web_WebPass) or out=&ok& thenResponse.Cookies(&Main_LoginPass&)=&&Main_LoginPass=&&end ifconnstr=&DBQ=&+server.mappath(Web_MdbUrl)+&;DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};&set conn=server.createobject(&ADODB.CONNECTION&)conn.open connstrIF Err.Number && 0 ThenResponse.Write &数据库连接错误,请检查数据库连接文件!&Response.EndEnd IFsub CloseConn()set rs=nothingconn.closeset conn=nothingend sub'删除修改操作开始if Main_LoginPass&&&& thendel=request(&del&)sh=request(&sh&)id=request(&id&)re=request(&re&)if del&&&& thenconn.Execute(&delete from book where id=&&del&&&)end ifif sh&&&& and id&&&& thenid=int(id)sh=int(sh)conn.Execute(&update book set JXK_Types=&&sh&& where id=&&id&&&)elseif id&&&& thenconn.Execute(&update book set JXK_CeoRe='&&re&&' where id=&&id&&&)end ifend if'删除修改操作结束set rs=server.createobject(&adodb.recordset&)action=request(&action&)if action=&save& thenJXK_Myname=trim(request.form(&JXK_Myname&))JXK_Cat=trim(request.form(&JXK_Cat&))JXK_Content=trim(request.form(&JXK_Content&))if len(JXK_Myname)&2 or len(JXK_Myname)&12 thenResponse.Write &&script&alert('昵称须在2-12个字符以内!');parent.SendErr()&/script&&Call CloseConn()Response.Endend ifif len(JXK_Content)&5 or len(JXK_Content)&500 thenResponse.Write &&script&alert('留言内容须在3-500个字符以内!');parent.SendErr()&/script&&Call CloseConn()Response.Endend ifJXK_Content=Server.Htmlencode(JXK_Content)JXK_Content=Replace(JXK_Content,CHR(13),&&br&&)if JXK_Cat=&& then JXK_Cat=1if JXK_Cat=0 then JXK_Cat=1JXK_Cat=int(JXK_Cat)JXK_MyIp = Request.ServerVariables(&HTTP_X_FORWARDED_FOR&)If JXK_MyIp=&& Then JXK_MyIp=Request.ServerVariables(&REMOTE_ADDR&)if JXK_MyIp=&& thenResponse.Write &&script&alert('无法获取您的IP信息,系统禁止留言!')&/script&&Call CloseConn()Response.Endend ifrs.open &select * from Book&,conn,1,3rs.addnewrs(&Jxk_Content&)=Jxk_Contentrs(&JXK_Myname&)=JXK_Mynamers(&JXK_MyIp&)=JXK_MyIprs(&JXK_Cat&)=0rs(&JXK_Types&)=Web_SendTypers.updaters.closeCall CloseConn()Response.Write &&script&parent.SendOk()&/script&&Response.Endend ifpage=request(&page&)C=request(&C&)if C=&& then C=0C=int(C)'分页函数function Pageinc(pagenum,listnum)onpage=request(&page&)if onpage=&& then onpage=1pagenum=int(pagenum)onpage=int(onpage)pagelink=replace(request.querystring(),&page=&&request(&page&)&&&&,&&)pagelink=replace(pagelink,&page=&&request(&page&),&&)if pagelink&&&& then pagelink=&&&&pagelinkif onpage-2 & 1 thenfistpage=1elsefistpage=onpage-2end ifif pagenum-fistpage&9 and pagenum&9 then fistpage=pagenum-9if pagenum&fistpage+9 thenlastpage=fistpage+9elselastpage=pagenumend ifif pagenum&8 and lastpage-fistpage&9 thenfistpage=lastpage-8elseif pagenum&9 and lastpage-fistpage&9 thenfistpage=1end ifpageinc=pageinc&&&div style='margin-left:0px'&共&b&&&pagenum&&&/b&页&b&&&listnum&&&/b&条留言&if Main_LoginPass&&&& then pageinc=pageinc&& &a href='#' onclick=&&AjaxGet('List.asp?out=ok');return false&& style=&&color:#0000ff&&&[退出登陆]&/a&&pageinc=pageinc&&&/div&&if onpage&1 thenpageinc=pageinc&&&div&&a href=&&javascript:AjaxGet('List.asp?C=&&C&&')&&&|&&&/a&&/div&&pageinc=pageinc&&&div&&a href=&&javascript:AjaxGet('List.asp?C=&&C&&&page=&&onpage-1&&')&&&&&&/a&&/div& &elsepageinc=pageinc&&&div class=WinPageDis&|&&&/div&&pageinc=pageinc&&&div class=WinPageDis&&&&/div& &end iffor i=fistpage to lastpageif i&10 then ii=&0&&i else ii=iif onpage=i thenpageinc=pageinc&&&div class=WinPageCur&&&ii&&&/div& &elsepageinc=pageinc&&&div&&a href=&&javascript:AjaxGet('List.asp?C=&&C&&&page=&&i&&')&&&&&ii&&&/a&&/div& &end ifnextif onpage&pagenum and pagenum&&1 thenpageinc=pageinc&&&div&&a href=&&javascript:AjaxGet('List.asp?C=&&C&&&page=&&onpage+1&&')&&&&&&/a&&/div& &pageinc=pageinc&&&div&&a href=&&javascript:AjaxGet('List.asp?C=&&C&&&page=&&pagenum&&')&&&&&|&/a&&/div&&elsepageinc=pageinc&&&div class=WinPageDis&&&&/div& &pageinc=pageinc&&&div class=WinPageDis&&&|&/div&&end ifpageinc=pageinc&&&/ul&&end function'各种日期格式转换Function DateFormat(DateStr)Hours=Hour(DateStr)if Hours&10 then Hours=&0&&HoursMinutes=int(Minute(DateStr))if Minutes&10 then Minutes=&0&&MinutesMonths=month(DateStr)if Months&10 then Months=&0&&Monthsdays=day(DateStr)if days&10 then days=&0&&daysDateString = right(year(DateStr),2)&&-&&Months&&-&&days&& &&Hours&&:&&MinutesDateFormat = DateStringEnd Functiondim PageListsql=&select * from book&if C&&0 then sql=sql&& where JXK_Cat=&&C&&&sql=sql&& order by id desc&rs.open sql,conn,1,1if rs.eof thenPageList=&&p style='text-align:padding:10px'&还没有网友留言!&/a&&elsers.PageSize=Web_PageNumpre = true last = true if len(page) = 0 then intpage = 1 pre = false else if cint(page) =& 1 then intpage = 1 pre = false elseif cint(page) &= rs.PageCount then intpage = rs.PageCount last = false else intpage = cint(page) end if end if end if if not rs.eof thenrs.AbsolutePage = intpage end if for i=1 to rs.PageSizeif rs.EOF or rs.BOF then exit forJXK_MyIp=rs(&JXK_MyIp&)if Main_LoginPass=&& then JXK_MyIp=left(JXK_MyIp,len(JXK_MyIp)-len(split(JXK_MyIp,&.&)(3)))&&*&jxk_content=HtmlEnCode(rs(&jxk_content&))if rs(&JXK_Types&)=0 and Main_LoginPass=&& then jxk_content=&&DIV style='width:100height=10margin-top:1position:top:20LEFT:500'&&img src='q.gif'/&&/DIV&&font align=center style='color:#padding-top:10padding-bottom:10'&&del&&&jxk_content&&&/del&&/font&&PageList=PageList&&&div class='JXK_List'&&PageList=PageList&&&div class='List1'&&div class='List1_1'&&img src='book/icon.gif' align='absmiddle'& &b&&&rs(&JXK_MyName&)&&&/b& &font style='color:#666666;font-size:12px'&IP:&&JXK_MyIp&&&/font&&/div&&div class='List1_2'&&&rs(&jxk_time&)&&&/div&&/div&&PageList=PageList&&&div class='List2'&&&jxk_content&&&/div&&if Main_LoginPass&&&& thenPageList=PageList&&&div class='List3'&--------------------------------------------------&br&&font style='color:#;&管理员回复:&/font&&PageList=PageList&&&input type='text' id='re_&&rs(&id&)&&' size=64 class='JXK_inp' value='&&rs(&JXK_CeoRe&)&&'& &input type='button' value='保存' class='JXK_button' onclick=&&AjaxGet('list.asp?page=&&page&&&id=&&rs(&id&)&&&re='+$('re_&&rs(&id&)&&').value)&&& &input type='button' value='删除' class='JXK_button' onclick=&&if(confirm('确认删除?')){AjaxGet('list.asp?page=&&page&&&del=&&rs(&id&)&&')}&&& &if rs(&JXK_Types&)=0 thenPageList=PageList&&&input onclick=&&AjaxGet('list.asp?page=&&page&&&sh=1&id=&&rs(&id&)&&')&& type='button' value='审核' class='JXK_button' style='color:#0000ff'&&elsePageList=PageList&&&input onclick=&&AjaxGet('list.asp?page=&&page&&&sh=0&id=&&rs(&id&)&&')&& type='button' value='取消审核' class='JXK_button'&&end ifPageList=PageList&&&/div&&elseif rs(&JXK_CeoRe&)&&&无& and len(rs(&JXK_CeoRe&))&0 thenPageList=PageList&&&div class='List3'&--------------------------------------------------&br&&font style='color:#;&管理员回复:&/font&&&rs(&JXK_CeoRe&)&&&/div&&end ifend ifPageList=PageList&&&/div&&rs.movenextnextend ifPageList=PageList&&&div class='WinPage'&&&Pageinc(rs.PageCount,rs.RecordCount)&&&/div&&rs.closeCall CloseConn()Response.Write PageList%&
加下面代码,增加查找功能,求助,谢谢&form name=&form2& method=&post& action=&index.asp&&筛选:&select name=&sokind& class=&celect&&&option selected value=&Jxk_Content+JXK_Myname+JXK_Time+s2+JXK_CeoRe+JXK_MyIp&&全 部&/option&
&option value=&Jxk_Content&&内 容&/option&&option value=&JXK_Time&&日 期&/option&&option value=&JXK_Myname&&称 呼&/option&
&关键字:&input class=&JXK_Inp& name=&keyword& onfocus=&if(this.value=='请输入关键字')this.value=''& value=&请输入关键字& onBlur=&return checkUserName();& type=&text& size=&30& maxlength=&50&&&input name=&Submit2& type=&submit& class=&button& value=& 搜 索 &/&&/form&
登录百度帐号

我要回帖

更多关于 asp连接access数据库 的文章

 

随机推荐