(0x80004005) Data source name not found

(0x80004005) Data source name not found

am 08.10.2007 10:30:22 von navin

Hi 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
%>



<%= Session("dbTitle") %>




<%
' 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 %>
 






BGCOLOR=#99CCCC>

<% For x = 1 to intFieldCount
If Mid(strDisplay, x, 1) = "1" Then
strConn = "ORDER=" & x
' Don't display BLOB's as sortable
If aFields(x,2) = 201 Then %>

<% Else %>


<%
intCount = 0
Do While NOT xrs.EOF
intCount = intCount + 1 %>
<%
x = 0
For Each xField in xrs.Fields
x = x + 1
curVal = xField.Value
' Every other line will have a shaded background
If intCount mod 2 = 0 Then
bgcolor="#FFFFCC"
Else
bgcolor="White"
End If
' If on the Key field, build the link used to load the Viewer,
Editor, or Deleter
If x = CInt(intPrimary) Then
Session("zcurTable") = strTable
Session("zcurDisplay") = strDisplay
Session("zcurKeyField") = aFields(x,1)
strLink = "KEY=" & xField.Value
End If
If Mid(strDisplay, x, 1) = "1" Then %>
<%
End If
Next
If (Session("dbDispView") <> "") and Session("dbKey") > 0 Then %>

<% End If
xrs.MoveNext %>

<% Loop %>
<%=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

Re: (0x80004005) Data source name not found

am 08.10.2007 14:20:52 von reb01501

navin wrote:
>
> ' Open Connection to the database
> set xConn = Server.CreateObject("ADODB.Connection")
> xConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath
> & ";"

This is not the connection string to use for an ODBC DSN. However, I would
suggest forgetting about using a DSN and supplying the actual file path to
your database file in strDBPath.


--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

Re: (0x80004005) Data source name not found

am 12.10.2007 11:04:38 von Daniel Crichton

Bob wrote on Mon, 8 Oct 2007 08:20:52 -0400:

> navin wrote:

>> ' Open Connection to the database set xConn =
>> Server.CreateObject("ADODB.Connection")
>> xConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
>> strDBPath & ";"

> This is not the connection string to use for an ODBC DSN. However, I
> would suggest forgetting about using a DSN and supplying the actual
> file path to your database file in strDBPath.


Looking at the original code that's exactly what was being done:

strDBPath = Server.MapPath("acsdata.mdb")

So the intro about a System DSN was completely irrelevant because nowhere in
that code is the DSN being referenced.

--
Dan

Re: (0x80004005) Data source name not found

am 12.10.2007 12:20:03 von reb01501

Daniel Crichton wrote:
> Bob wrote on Mon, 8 Oct 2007 08:20:52 -0400:
>
>> navin wrote:
>
>>> ' Open Connection to the database set xConn =
>>> Server.CreateObject("ADODB.Connection")
>>> xConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
>>> strDBPath & ";"
>
>> This is not the connection string to use for an ODBC DSN. However, I
>> would suggest forgetting about using a DSN and supplying the actual
>> file path to your database file in strDBPath.
>
>
> Looking at the original code that's exactly what was being done:
>
> strDBPath = Server.MapPath("acsdata.mdb")
>
> So the intro about a System DSN was completely irrelevant because
> nowhere in that code is the DSN being referenced.

Then he either misreported his error message: "[Microsoft][ODBC Driver
Manager] ..." or he has not shown us the actual code..

If the former, then this is likely to be a permissions problem and he needs
to make sure the user has read-write permissions to the folder containing
the database. If using Anonymous, then the user is the IUSR_machinename
account.

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"