(0x80004005) Data source name not found
am 08.10.2007 10:30:22 von navinHi All,
I am trying to connect to the database through DSN. i have set it up
as System DSN, but when i open the page, i get error "(0x80004005)
[Microsoft][ODBC Driver Manager] Data source name not found and no
default driver specified.
below is the code which i am using:
<%
' Quick security check, make sure we have an active session
'If Session("dbDispList") = "" or Session("dbConn") = "" Then
Response.Redirect "GenericError.asp"
Dim strDBPath ' path to our Access database (*.mdb) file
' Get the parameters set in the Config File
strType = UCase(Session("dbType"))
strConn = Session("dbConn")
strTable = Session("dbRs")
strDisplay = Session("dbDispList")
strWhere = Session("dbWhere")
intPrimary = Session("dbKey")
intOrderBy = Session("dbOrder")
strDBPath = Server.MapPath("acsdata.mdb")
' Check to see if the Order was specified by a parameter
If Request.QueryString("ORDER").Count > 0 Then
' Check if an ASC/DESC toggle is required (- for desc, + for asc)
if abs(intOrderBy) = abs(Request.QueryString("ORDER")) then
intOrderBy = 0 - intOrderBy
else
intOrderBy = Request.QueryString("ORDER")
end if
Session("dbOrder") = intOrderBy
End If
' Open Connection to the database
set xConn = Server.CreateObject("ADODB.Connection")
xConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath
& ";"
' Open Recordset and get the field info
strsql = "SELECT * FROM [" & strTable & "]"
Select Case strType
Case "UDF"
strsql = "SELECT " & strFields & " FROM " & strTable
Case "SQL"
strsql = Replace(strsql,"[","")
strsql = Replace(strsql,"]","")
End Select
set xrs = Server.CreateObject("ADODB.Recordset")
xrs.Open strsql, xConn
intFieldCount = xrs.Fields.Count
Dim aFields()
ReDim aFields(intFieldCount,3)
For x = 1 to intFieldCount
aFields(x, 1) = xrs.Fields(x-1).Name
aFields(x, 2) = xrs.Fields(x-1).Type
aFields(x, 3) = xrs.Fields(x-1).DefinedSize
Next
xrs.Close
Set xrs = Nothing
%>
<%
' Reopen the Recordset using the parameters passed
strsql = "SELECT * FROM [" & strTable & "]"
Select Case strType
Case "UDF"
strsql = "SELECT " & strFields & " FROM " & strTable
Case "SQL"
strsql = Replace(strsql,"[","")
strsql = Replace(strsql,"]","")
End Select
If (strWhere & "x") <> "x" Then strsql = strsql & " WHERE " & strWhere
If intOrderBy <> 0 Then
if intOrderBy > 0 then
strsql = strsql & " ORDER BY [" & aFields(intOrderBy, 1) & "]"
else
strsql = strsql & " ORDER BY [" & aFields(abs(intOrderBy), 1) & "]
DESC"
end if
end if
set xrs = Server.CreateObject("ADODB.Recordset")
xrs.Open strsql, xConn, 1, 2
%>
<%= Session("dbTitle") %> | <% If Session("dbCanAdd") = 1 Then %> | GenericEdit.asp? CMD=NEW">Add New Record <% End If %> | <% If Session("dbDebug") = 1 Then %> | %>GenericInfo.asp">db Info <% End If %> |
<%=aFields(x,1)%> | TH> <% End If End If Next %> | ||
---|---|---|---|
ALIGN="LEFT"> <% ' Empty / Null / Blank If IsNull(curVal) OR (Trim(curVal) & "x" = "x") Then curVal = " " ' Password If UCase(Left(aFields(x,1),8)) = "PASSWORD" Then curVal = "*****" ' Image If (UCase(Left(aFields(x,1),3)) = "IMG") Then If Session("dbMaxImageSize") = 0 Then curVal = LT & "IMG SRC=" & QUOTE & curVal & QUOTE & GT Else curVal = LT & "IMG SRC=" & QUOTE & curVal & QUOTE & " WIDTH=" & QUOTE & Session("dbMaxImageSize") & QUOTE & GT End If End If ' Date / Time If aFields(x,2) = 135 Then curVal = FormatDateTime(curVal,2) ' Boolean If aFields(x,2) = 11 Then If curVal Then curVal = "Yes" Else curVal = "No" End If End If ' Currency If aFields(x,2) = 6 Then curval = FormatCurrency(curval,2,-1) ' Integers, Currency - right align If (aFields(x,2) = 3) OR (aFields(x,2) = 6) Then curVal = " align=right>" & curVal & "" ' Display Memo field, replace carriage returns with tags. If aFields(x,2) = 201 Then curVal = replace(curVal,chr(10)," ") Response.Write curVal %> | <% ALIGN="RIGHT">GenericView.asp?<%= strLink %>">View TD> <% End If If (Session("dbCanEdit") = 1) and Session("dbKey") > 0 Then %> | ALIGN="RIGHT">GenericEdit.asp?<%= strLink %>">Edit TD> <% End If If (Session("dbCanDelete") = 1) and Session("dbKey") > 0 Then %> | ALIGN="RIGHT">GenericDelete.asp?<%= strLink %>">Delete A> |
<%
Response.Write intCount & " records"
xrs.Close
Set xrs = Nothing
xConn.Close
Set xConn = Nothing
%>
Please help.
thanks,
navin