?
Solved

Getting an error "unrecognized escape sequence

Posted on 2003-10-25
4
Medium Priority
?
472 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 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

809 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