|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
ASP Data Source not found
Im trying to build an ASP page to display all fields within a table thats in an access database.
Im using somee.com to host my database and site, but when i try to access my page i get this error. Microsoft OLE DB Provider for ODBC Drivers error '80004005' [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified /Index.asp, line 8 I know that my database name and table name are correct and really don't know what to do but really need to fix it. If anyone has any ideas, I will really appreciate it. Code:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
id = request.querystring("id") 'request the information that is being passed across pages
set con=server.createobject("ADODB.Connection")
con.open "eminence/db/EminenceDiscos.mdb"
set rs=server.CreateObject("ADODB.Recordset")
sqlquery = "SELECT * FROM CDInformation WHERE id=" &id
set rs=con.execute(sqlquery)
%>
<html>
<head>
<title>CD Information</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<table border=1>
<tr>
<td align="center">
<b>ID</b>
</td>
<td align="center">
<b>CD Name</b>
</td>
<td align="center">
<b>Artist</b>
</td>
<td align="center">
<b>Release Date</b>
</td>
<td align="center">
<b>Genre</b>
</td>
<td align="center">
<b>Image</b>
</td>
</tr>
<tr>
<td width="17%">
<%=rs("CD ID")%>
</td>
<td width="17%">
<%=rs("CD Name")%>
</td>
<td width="17%">
<%=rs("Artist")%>
</td>
<td width="17%">
<%=rs("Release Date")%>
</td>
<td width="17%">
<%=rs("Genre")%>
</td>
<td width="17%">
<img src="..\<%=rs("Image")%>" height="120" width="120" alt="<%=rs("Title")%>">
</td>
</tr>
</table>
</body>
</html>
|
|
#2
|
||||
|
||||
|
not too sure but try this
Code:
con.open Server.mappath("EminenceDiscos.mdb")
![]() |
|
#3
|
||||
|
||||
|
I think that you also need to specify the Provider. If you are using MS Access it would be something like this:
Code:
Dim filePath
filePath = Server.mappath("EminenceDiscos.mdb")
con.open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & filePath & ";"
Check out Connection Strings.com for help with your connection string. |
|
#4
|
||||
|
||||
|
Try somthing like this...
Code:
Set Con = Server.CreateObject("ADODB.Connection")
src = Server.MapPath("db/EminenceDiscos.mdb")
sConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & src
Con.Open sConnStr
__________________
Hope this advice helps.
If so please show your appreciation by adding reputation points (click gauge image on top right of this post).- Post your code - Post your errors - Be clear - Be courteous - AND PLEASE...Finalise your thread with a solution or confirmation that the last advice worked or failed. Visit My ASP Free Members Club Profile |
|
#5
|
|||
|
|||
|
Thanks for the replies, have just tried what icoombs suggested and it appears to work, however, I have now received the error.
Microsoft VBScript runtime error '800a000d' Type mismatch: 'rs' /Index.asp, line 52 This is when I'm trying to match whats in the database to the page so that I can show what is in the database. I'm not sure what this means. Sorry for all the questions! |
|
#6
|
||||
|
||||
|
It could be that you are comparing two different datatypes, if this is the case you could use CStr() to force both values to strings.
Which is line 52? Last edited by sync_or_swim : February 10th, 2009 at 11:36 AM. |
|
#7
|
|||
|
|||
|
Line 52 is <%=rs("CD ID")%>
The start of getting the data from the database. Sorry about sounding dumb, how you I go about forcing both values to be strings by using CStr(), where would I put that? Thanks |
|
#8
|
||||
|
||||
|
Don't worry about forcing anything to uppercase, that would only apply if you were doing a comparison.
Do you have a field in your recordset called CD Id? I'm not sure but you may not be able to use the space, if you alias the field name in your sql - SELECT [CD ID] AS CD_ID - then you can refer to this field with an underscore instead of a space |
|
#9
|
|||
|
|||
|
I've changed the fields in my database so that they dont have spaces and done the same to the code, but still getting the same error :S
|
|
#10
|
||||
|
||||
|
Post more of the code including the Query.
|
|
#11
|
||||
|
||||
|
id comes in through the query string as a string here:
id = request.querystring("id") If ID is a numeric field in your database it will throw that data type mismatch error. Try this: form_id = request.querystring("id") id = CInt(form_id) and see what happens. |
|
#12
|
|||
|
|||
|
Just realised I'd taken the query out of the code I think.
This is my full code Code:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
form_id = request.querystring("id")
id = CInt(form_id)
Set Con = Server.CreateObject("ADODB.Connection")
src = Server.MapPath("db/EminenceDiscos.mdb")
sConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & src
Con.Open sConnStr
set rs=server.CreateObject("ADODB.Recordset")
sqlquery = "SELECT * FROM CDInformation WHERE id=" &id
%>
<html>
<head>
<title>CD Information</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<table border=1>
<tr>
<td align="center">
<b>ID</b>
</td>
<td align="center">
<b>CD Name</b>
</td>
<td align="center">
<b>Artist</b>
</td>
<td align="center">
<b>Release Date</b>
</td>
<td align="center">
<b>Genre</b>
</td>
<td align="center">
<b>Image</b>
</td>
</tr>
<tr>
<td width="17%">
<%=rs("CDID")%>
</td>
<td width="17%">
<%=rs("CD_Name")%>
</td>
<td width="17%">
<%=rs("Artist")%>
</td>
<td width="17%">
<%=rs("Release_Date")%>
</td>
<td width="17%">
<%=rs("Genre")%>
</td>
<td width="17%">
<img src="..\<%=rs("Image")%>" height="120" width="120" alt="<%=rs("Title")%>">
</td>
</tr>
</table>
</body>
</html>
The rs error has now gone, but now im getting ADODB.Recordset error '800a0cc1' Item cannot be found in the collection corresponding to the requested name or ordinal. /Index.asp, line 55 Sorry for being such a pain |
|
#13
|
||||
|
||||
|
I can't see where you are populating the recordset. I would expexct to see:
Code:
set rs=server.CreateObject("ADODB.Recordset")
sqlquery = "SELECT * FROM CDInformation WHERE id=" &id
Set rs = con.Execute(sqlquery)
If rs.EOF <> True And rs.BOF <> True Then
'etc.....
|
|
#14
|
|||
|
|||
|
Thanks, ive added them lines, I'd deleted the first one earlier by accident.
Im now getting Microsoft VBScript compilation error '800a03f6' Expected 'End' /Index.asp, line 71 But looks like getting closer to the fix |
|
#15
|
||||
|
||||
|
Quote:
if you literally went w/ sync's snippet then you are missing an end if you have to post relevant code: as sync mentioned he did not see where you were creating the recordset... we simply do not have the time to always test the posted code...we simply guide...so don't always take posted code as literally going to work...you have to do some tutorials...i understand you are new...but what you are asking is trivial and you should be learning from tutorials versus diving into code blindly...soon enough you will be teaching others Code:
<%
form_id = request.querystring("id")
If isNumeric(form_id) Then
form_id = CINt(form_id)
Set Con = Server.CreateObject("ADODB.Connection")
src = Server.MapPath("db/EminenceDiscos.mdb")
sConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & src
Con.Open sConnStr
Set rs = con.Execute("SELECT * FROM CDInformation WHERE id=" & form_id)
If Not rs.EOF Then
iCDID = rs("CDID")
sCD_Name = rs("CD_Name")
Response.Write "<table border=""1"">" & _
" <tr>" & _
" <th>CD ID</th>" & _
" <th>CD Name</th>" & _
" </tr>" & _
" <tr>" & _
" <td>" & iCDID & "</td>" & _
" <td>" & sCD_Name & "</td>" & _
" </tr>" & _
"</table>"
End If
End If
%>
__________________
Please give respect to those that helped solve an issue by clicking on the reputation icon
Last edited by keep_it_simple : February 11th, 2009 at 12:01 AM. |
![]() |
| Viewing: ASP Free Forums > Programming > ASP Development > ASP Data Source not found |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|