关于ASP中CONN.ASP代码解读
请问高手这段代码有没有错误,系统提示:Microsoft OLE DB Provider for ODBC Drivers 错误 '***********'
[Microsoft][ODBC 驱动程序管理器] 未发现数据源名称并且未指定默认驱动程序
/web/conn.asp,行 13
<%
response.write "<font size=1px color=white>-_-b</font>"
function FormatStr(fString)
if fString <> "" then
fString = replace(fString, vbCrLf,"<br>")
fString = replace(fString, chr(32)&chr(32)," ")
end if
FormatStr = fString
end function
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "lsjmwodbc","",""
sql = "driver={microsoft access driver (*.mdb)};Pwd=xo2002;dbq=\database\database.mdb"
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open sql
%>
<script language=javascript>
function CheckDelete()
{
return confirm("确实删除吗?");
}
</script>
参考答案:Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "lsjmwodbc","",""
sql = "driver={microsoft access driver (*.mdb)};Pwd=xo2002;dbq=\database\database.mdb"
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open sql
这几句有错误
改为这样就可以了
sql = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath("/database/database.mdb")
Set conn = Server.CreateObject("ADODB.Connection")
conn.open sql