?
Solved

Getting an error "unrecognized escape sequence

Posted on 2003-10-25
4
Medium Priority
?
469 Views
Last Modified: 2012-08-13
I get a unrecognized charecter sequence error on this line
pathInfo="PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=c:\inetpub\wwwroot\contact\info.mdb";


Im trying to connect to the Access database info.mdb

code snippet is
OleDbDataReader dbRead;
                  string sConnectionString;
                  string pathInfo;
                  string sqlCommand;
                  pathInfo="PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=\\info.mdb";
                  OleDbConnection con = new OleDbConnection(pathInfo);
                  sqlCommand = "select * from contactInfo";
                  OleDbCommand com = new OleDbCommand(sqlCommand,pathInfo);
                  con.Open();
                  dbRead = com.ExecuteReader();
                  while(dbRead.Read())
                  {
                        response.write (dbRead.GetString(1));
                  }


could somebosy tell me what Im doing wrong
0
Comment
Question by:coolsahara
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 29

Accepted Solution

by:
David H.H.Lee earned 150 total points
ID: 9620790
coolsahara,
you had done somethings mistake in pathInfo, try to change to this solutions :
Instead of
 pathInfo="PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=\\info.mdb";

Change to
 pathInfo="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("info.mdb")

Regards
x_com
0
 

Author Comment

by:coolsahara
ID: 9620929
Thanks x_com,

Could you tell me what was wrong with the previous statement.

Now I get a new error
it says that the type or namespace name "server" could not be found in your statment.
0
 
LVL 58

Expert Comment

by:Gary
ID: 9620965
A \ is an escape character in javascript, try it with just a single \
0
 

Expert Comment

by:smacca
ID: 9622271
I can see your logic here however it is not the escape character that is the problem.
I assume your access database resides in the "root" directory - ie. "/info.mdb".

If so, the problem with your connection string path is that the ABSOLUTE FILE PATH is required.
For example, the path info should be something like:

  pathInfo="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Inetpub\\wwwroot\\info.mdb"

As coolsahara mentioned, if you want to use a RELATIVE PATH (as perhaps this makes more sense to you - this is most common) you would use:

  pathInfo="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("/info.mdb")

Hope it all works.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question