Solved

Getting an error "unrecognized escape sequence

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
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…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

911 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

23 Experts available now in Live!

Get 1:1 Help Now