Solved

Getting an error "unrecognized escape sequence

Posted on 2003-10-25
4
455 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
4 Comments
 
LVL 29

Accepted Solution

by:
David H.H.Lee earned 50 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

743 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now