Click to See Complete Forum and Search --> : Can anybody give me further details about the message:"Expected literal constant"


mpoincare
January 26th, 2003, 07:27 PM
I am trying to add a new record in a ms access database located in the following
physical path: C\Inetpub\wwwroot\plea\data\project.mdb on a windows2000 server. I
a using the following ASP code in order to do that:

<!-- #include file="adovbs.inc" -->
<%

Dim conn, sConnection
Const DB_CONNECTIONSTRING = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & Server.MapPath("project.mdb") & ";"

Session.TimeOut=60

Set conn = Server.CreateObject("ADODB.Connection")
conn.Open(DB_CONNECTIONSTRING)
%>
But the browser keeps displaying this error message:
Technical Information (for support personnel)

Error Type:
Microsoft VBScript compilation (0x800A0415)
Expected literal constant
/Plea/Data/AppLogic.asp, line 6, column 54
& "Data Source=" & Server.MapPath("project.mdb") & ";"
-----------------------------------------------------^
Can somebody explain me what the statement:"Expected literal constant" means in
a context like that and what can be done to fix it. I also tried to use the Physical
path to reach the database ( C\Inetpub\wwwroot\plea\data\project.mdb) and I still get the
same message. I am using IE4 (or IE5)

Thread1
January 27th, 2003, 05:49 AM
Check out on how you declare your constant variable! Constant variable should contain only literal string, no variables no objects no function calls etc.

Try this :

Dim conn, sConnection
Dim DB_CONNECTIONSTRING

DB_CONNECTIONSTRING = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & Server.MapPath("project.mdb") & ";"