Current location: Hot Scripts Forums » Programming Languages » ASP » ASP syntax error


ASP syntax error

Reply
  #1 (permalink)  
Old 11-18-04, 05:26 AM
stuckonaproject stuckonaproject is offline
Newbie Coder
 
Join Date: Nov 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy ASP syntax error

Hi all. I was wondering if someone could help me? I'm doing a big project using ASP which I've never used before and I'm really struggling. I really need to get it to work otherwise I'm gunna fail this project, so any help would be greatly appreciated. I'm trying to connect a database up and display all records. This is the code that the error is on:

db.open "DRIVER={Microsoft Access Driver(*.mdb)};DBQ=" &

it says its on column 57. I've messed with it for ages but nothing works. If I remove the & sign, the error message says:

Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

Can anyone explain why or know how to make it work?
thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 11-18-04, 11:13 AM
koncept
Guest
 
Posts: n/a
you need to fill in the dbq so that is points to the database
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 11-18-04, 04:45 PM
stuckonaproject stuckonaproject is offline
Newbie Coder
 
Join Date: Nov 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by koncept
you need to fill in the dbq so that is points to the database
Right. Well my db is called Staff Qualifications, so after the DBQ= I need to put "Staff_Qualifications" there? Thanks for helping me out I've been so worried about this project, I just want it to work
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 11-18-04, 09:23 PM
koncept
Guest
 
Posts: n/a
so the line would read

Code:
db.open "DRIVER={Microsoft Access Driver(*.mdb)};DBQ=" & server.mappath("staff qualifications.mdb")
assuming the database is in the same folder as the script it should work
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 11-19-04, 04:21 PM
stuckonaproject stuckonaproject is offline
Newbie Coder
 
Join Date: Nov 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by koncept
so the line would read

Code:
db.open "DRIVER={Microsoft Access Driver(*.mdb)};DBQ=" & server.mappath("staff qualifications.mdb")
assuming the database is in the same folder as the script it should work
yeah, its in the folder the book said to put it in. I wonder why the book didn't tell me to put that bit in? Oh well.. thanks so much for all your help, I can try your advice on Thursady when im next with my project. Fingers crossed, it will work!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 12-02-04, 03:59 AM
stuckonaproject stuckonaproject is offline
Newbie Coder
 
Join Date: Nov 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by stuckonaproject
yeah, its in the folder the book said to put it in. I wonder why the book didn't tell me to put that bit in? Oh well.. thanks so much for all your help, I can try your advice on Thursady when im next with my project. Fingers crossed, it will work!
Ahhh! It still won't work! And the wierd thing is it says the error is on line 10, then shows me line 5. I'll show you the whole code.
<%
dim orseof
set db=server.createobject("adodb.connection")
set orseof=server.createobject("adodb.recordset")
db.open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ="&_Server.MapPath("Staff Qualifications.mdb")

orseof.open "Contact Details",db

orseof.movefirst

response.write"<table boarder='1'>"
response.write"<tr><td>Staff_number</td>"
response.write"<td>Staff_type</td>"
response.write"<td>Employee_name</td>"
response.write"<td>Based_at</td>
response.write"<td>Street_name_and_number</td>
response.write"<td>Area</td>
response.write"<td>Town/city</td>
response.write"<td>Post_code</td>
response.write"<td>Home_phone_number</td>
response.write"<td>Mobile_number</td>
response.write"<td>Email_address</td>
response.write"<td>Inactive_member_of_staff</td></tr>"

do while not orseof.eof
response.write"<td>"&orseof("Staff_number")&"</td>"
response.write"<td>"& orseof("Staff_type")&"</td>"
response.write"<td>"& orseof("Employee_name")&"</td>"
response.write"<td>"& orseof("based_at")&"</td>"
response.write"<td>"& orseof("street_name_and_number")&"</td>"
response.write"<td>"& orseof("area")&"</td>"
response.write"<td>"& orseof("town/city")&"</td>"
response.write"<td>"& orseof("post_code")&"</td>"
response.write"<td>"& orseof("home_phone_number")&"</td>"
response.write"<td>"& orseof("mobile_number")&"</td>"
response.write"<td>"& orseof("email_address")&"</td>"
response.write"<td>"& orseof("inactive_member_of_staff")&"</td>"</tr>"
orseof.movenext
loop
response.write"</table><br>"

%>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 12-02-04, 11:07 AM
koncept
Guest
 
Posts: n/a
two things 1 you do not need the movefirst which may cause an error, when you open a db it is on the firstrecord. 2. you do not need the &_server it should be & Server

this is the correct code

Code:
<%
dim orseof
set db=server.createobject("adodb.connection")
set orseof=server.createobject("adodb.recordset")
db.open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("Staff Qualifications.mdb")

orseof.open "Contact Details",db

response.write"<table boarder='1'>"
response.write"<tr><td>Staff_number</td>"
response.write"<td>Staff_type</td>"
response.write"<td>Employee_name</td>"
response.write"<td>Based_at</td>
response.write"<td>Street_name_and_number</td>
response.write"<td>Area</td>
response.write"<td>Town/city</td>
response.write"<td>Post_code</td>
response.write"<td>Home_phone_number</td>
response.write"<td>Mobile_number</td>
response.write"<td>Email_address</td>
response.write"<td>Inactive_member_of_staff</td></tr>"

do while not orseof.eof
response.write"<td>"&orseof("Staff_number")&"</td>"
response.write"<td>"& orseof("Staff_type")&"</td>"
response.write"<td>"& orseof("Employee_name")&"</td>"
response.write"<td>"& orseof("based_at")&"</td>"
response.write"<td>"& orseof("street_name_and_number")&"</td>"
response.write"<td>"& orseof("area")&"</td>"
response.write"<td>"& orseof("town/city")&"</td>"
response.write"<td>"& orseof("post_code")&"</td>"
response.write"<td>"& orseof("home_phone_number")&"</td>"
response.write"<td>"& orseof("mobile_number")&"</td>"
response.write"<td>"& orseof("email_address")&"</td>"
response.write"<td>"& orseof("inactive_member_of_staff")&"</td>"</tr>"
orseof.movenext
loop
response.write"</table><br>"

%>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #8 (permalink)  
Old 12-14-04, 08:48 AM
PTH PTH is offline
New Member
 
Join Date: Dec 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
I dont think this is ASP coding error. Im stucking in it too, and
Code:
<%
dim orseof
set db=server.createobject("adodb.connection")
set orseof=server.createobject("adodb.recordset")
db.open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("Staff Qualifications.mdb")

orseof.open "Contact Details",db  
...
%>

↑---This block is the error source
Im sure of it because even with only those code the error still appear, no matter how many time i try to connect to my database. I've try at least 3 times, delete then re-type to make sure there is no coding error...
Maybe try this will help you.

SYMPTOMS
When you use ActiveX Data Objects (ADO) or ODBC to open a database connection in an Active Server Pages (ASP) page, you may receive the following error message:
Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified.
CAUSE
This error can occur when you use a DSN-based connection string (a connection string that uses a System DSN) or a DSN-less connection string with ADO and ODBC to open a database connection in an ASP page. The common causes of this error are listed below.
Using an ODBC DSN
• The Microsoft Windows NT 4.0 or Windows 2000 user account that is used to process the request for the ASP page does not have sufficient permissions to read the registry key that stores the specified DSN's configuration information.
• The System ODBC DSN that is specified in the ADO connection string does not exist on the IIS server.
• The ASP Application or Session variable that is initialized in the ASP application's Global.asa file (or in an ASP page that is accessed before the page that contains the database connection code) is used to specify the ADO connection string. This connection string variable is not initialized when the code to open the database connection is run. To confirm this, add a Response.Write statement before the line of code that opens the database connection to display the connection string that is stored in the variable.

Using a DSN-Less Connection String
• The Windows NT 4.0 or Windows 2000 user account that is used to process the request for the ASP page does not have sufficient permissions to read the registry key that stores the specified ODBC Driver's configuration information. The Driver parameter in a DSN-less connection string specifies the ODBC driver that is used to establish the database connection.
• The name of the ODBC driver that is specified in the connection string is misspelled or specifies a driver that is not installed on the Internet Information Server (IIS) server.
• The ASP Application or Session variable that is initialized in the ASP application's Global.asa file (or in an ASP page that is accessed before the page that contains the database connection code) is used to specify the ADO connection string. This connection string variable is not initialized when the code to open the database connection is run. To confirm this, add a Response.Write statement before the line of code that opens the database connection to display the connection string that is stored in the variable.

RESOLUTION
WARNING: If you use Registry Editor incorrectly, you may cause serious problems that may require you to reinstall your operating system. Microsoft cannot guarantee that you can solve problems that result from using Registry Editor incorrectly. Use Registry Editor at your own risk.

Using an ODBC DSN
Insufficient Permissions to Read the DSN Registry Key
Grant the Windows NT 4.0 or Windows 2000 user account Read access to the specified ODBC System DSN registry key as follows: 1. Determine which account is used to process the request for the ASP page.
2. From the Start menu, click Run, type regedt32.exe, and then click OK to start Registry Editor.
3. In the HKEY_LOCAL_MACHINE window, browse to the HKLM\SOFTWARE\ODBC\ODBC.INI key. The ODBC.INI key contains a subkey for each ODBC SYSTEM DSN that is registered on the server.
4. Click the DSN registry key for the DSN that is specified in the ADO connection string.
5. From the Security menu, click Permissions.
6. Add the user account that you identified in step 1 to the list of users who can access this key, and select the Read check box for this user.
7. Click Apply, and then close Registry Editor.

Specified DSN Does Not Exist on the IIS Server
Create the specified System ODBC DSN on the IIS Server.
Global.asa Code to Initialize the ADO Connection String Is Not Running
1. Verify that the IIS Application folder has been set up as an IIS virtual directory with permissions to execute scripts.
2. Verify that the Global.asa file is located in the IIS application's root directory.
3. If the Application folder is already set up as an IIS virtual directory, remove and re-create the IIS application.
4. Refer to the articles that are listed in the "References" section to determine if any of these articles apply to your specific scenario.
5. Contact Microsoft Product Support Services if the code in Global.asa still does not appear to be running after you perform the preceding steps.

Using a DSN-Less Connection String
Insufficient Permissions to Read the Specified ODBC Driver Registry Key
Grant the Windows NT 4.0 or Windows 2000 user account Read access to the specified ODBC Driver registry key as follows: 1. Determine which account is used to process the request for the ASP page.
2. From the Start menu, click Run, type regedt32.exe, and then click OK to start Registry Editor.
3. In the HKEY_LOCAL_MACHINE window, browse to the HKLM\SOFTWARE\ODBC\ODBCINST.INI key. The ODBCINST.INI key contains a subkey for each ODBC Driver that is installed on the server.
4. Click the Driver registry key for the Driver that is specified in the ADO connection string.
5. From the Security menu, click Permissions.
6. Add the user account that you identified in step 1 to the list of users who can access this key, and select the Read check box for this user.
7. Click Apply, and then close Registry Editor.

Driver Name Is Misspelled or Is Not Installed on the IIS Server
Verify that the ODBC Driver name is spelled correctly in the ADO connection string. In addition, verify that the specified driver is installed on the IIS Server. To view a list of ODBC drivers that are installed on a system, look in the ODBC Data Source Administrator (Odbcad32.exe) on the Drivers tab.
Global.asa Code to Initialize the ADO Connection String Is Not Running
1. Verify that the IIS Application folder has been set up as an IIS virtual directory with permissions to execute scripts.
2. Verify that the Global.asa file is located in the IIS application's root directory.
3. If the Application folder is already set up as an IIS virtual directory, remove and re-create the IIS application.
4. Refer to the articles that are listed in the "References" section to determine if any of these articles apply to your specific scenario.
5. Contact Microsoft Product Support Services if the code in Global.asa still does not appear to be running after you perform the preceding steps.

STATUS
This behavior is by design.
MORE INFORMATION
The Windows NT 4.0 or Windows 2000 user account whose credentials are used to process a request for an ASP page is determined by the authentication mechanism that the Web Server uses to authenticate the user request. For example, if you use Anonymous authentication, the credentials of the configured IIS Anonymous account (the IUSR_<WebServerName> account by default) is used to process the user request. When you use Basic authentication, Microsoft Internet Explorer prompts the user to supply a valid Windows NT 4.0 or Windows 2000 Network UserId and password whose credentials are then used to process the request. For additional information about the supported authentication mechanisms and how they work, refer to the online IIS documentation.


This is what i got from Microsoft support center, and this is the link:
http://support.microsoft.com/kb/306345/EN-US

Thanks godness, after trying those way that error still appear!!
There is much topic about this error available on internet, but seem like the error still there. Just go to google and paste the error code in. Maybe you will find something out there.
I totally lose to this error! Maybe because i use WinXP? Anyone there can help me...
Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #9 (permalink)  
Old 12-14-04, 11:30 AM
koncept
Guest
 
Posts: n/a
Code:
<%
dim orseof,db,strsql

set db=server.createobject("adodb.connection")
set orseof=server.createobject("adodb.recordset")
db.open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("Staff Qualifications.mdb")

strsql="select * from tablename"
orseof.open strsql, db  
%>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
You have an error in your SQL syntax. Help! SevEre PHP 7 09-08-04 06:05 AM
Server object error 'ASP 0177 : 800401f3' violet ASP 3 09-02-04 10:02 PM
syntax error plz help darkcarnival PHP 40 08-10-04 05:02 AM
Syntax error code 0 bw1150 The Lounge 0 02-20-04 08:48 PM
Syntax error (missing operator) in query expression crobinson ASP 4 11-23-03 09:49 PM


All times are GMT -5. The time now is 09:47 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.