Solved

Getting an error "unrecognized escape sequence

Posted on 2003-10-25
4
465 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SMS AddAttachment Protocol Error Classic ASP 10 45
Need help to rewrite script 3 95
Button to go back 3 28
Save ms data to server side. 19 55
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…
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/…

831 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