khubaib
Posts: 8
|
Posted: 01/10/2006, 11:24 AM |
|
I try to set path in server for database but not...
error is
Parser Error Message: The '&' character, hexadecimal value 0x26, cannot begin with a name. Line 19, position 99.
Source Error:
Line 17: <appSettings>
Line 18:
Line 19: <add key="Connection1String" value= "Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source=" & Server.MapPath("result.mdb") & ";Persist Security Info=False"
Line 20: <add key="Connection1Type" value="OleDb"/>
Line 21: <add key="Connection1Server" value="MSAccess"/>
What is problem,
thanks
|
|
|
E43509
Posts: 283
|
Posted: 01/10/2006, 11:37 AM |
|
Within your web.config, I don't believe you are allowed to 'concatenate' as you have done. XML is strict and everything after value is between the double quotes.
|
|
|
khubaib
Posts: 8
|
Posted: 01/10/2006, 12:21 PM |
|
Please explaine me more,
|
|
|
dragoon
Posts: 173
|
Posted: 01/11/2006, 12:50 AM |
|
you can't use Server.MapPath in web.config
but you can try something different:
<add key="Connection1String" value= "Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source=" />
<add key="Connection2String" value="path\database.mdb" />
and later call it this way:
OleDbConnection con = new OleDbConnection(ConfigurationSettings.AppSettings["Connection1String"]) + Server.MapPath(ConfigurationSettings.AppSettings["Connection2String"]));
|
|
|
khubaib
Posts: 8
|
Posted: 01/11/2006, 8:13 AM |
|
Thanks Dragoon your reply, i try but i have not success, Can you give me more advice. thanks
these code which create by codecharge,
<add key="Connection1String" value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Projects\school\result.mdb;Persist Security Info=False;User ID=Admin;Password="/>
<add key="Connection1Type" value="OleDb"/>
<add key="Connection1Server" value="MSAccess"/>
|
|
|
dragoon
Posts: 173
|
Posted: 01/11/2006, 6:35 PM |
|
hi there,
the code above wasn't for you to copy paste, but just to get an ideea
<add key="Connection1String" value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="/>
<add key="Connection2String" value="D:\Projects\school\result.mdb"/>
<add key="Connection3String" value=";Persist Security Info=False;User ID=Admin;Password="/>
<add key="Connection1Type" value="OleDb"/>
<add key="Connection1Server" value="MSAccess"/>
now you need to find where is your connection string is made.
usually in "/components/Setting.cs" in the project folder.
OleDbConnection con = new OleDbConnection(ConfigurationSettings.AppSettings["Connection1String"]) + Server.MapPath(ConfigurationSettings.AppSettings["Connection2String"]) + ConfigurationSettings.AppSettings["Connection3String"]));
what lang. are you using? vb.net / c#
|
|
|
khubaib
Posts: 8
|
Posted: 01/11/2006, 10:23 PM |
|
vb.net
|
|
|
khubaib
Posts: 8
|
Posted: 01/11/2006, 10:51 PM |
|
Quote khubaib:
vb.net (i am new in this field
|
|
|
Allen Kuo
|
Posted: 01/12/2006, 5:17 AM |
|
Hi
Step1:
Project / Settings --> Create a Connection(name=Connection1)
uncheck 'Same as Design' and input your connection string
Provider=Microsoft.Jet.OLEDB.4.0;Data Source={db};Persist Security
Info=False
Step2:
Open Settings.vb file and find these code:
===============
Public Shared ReadOnly Property Connection1Connection As
ConnectionString
Get
Dim cs As ConnectionString = New ConnectionString()
cs.Connection =
System.Configuration.ConfigurationSettings.AppSettings("Connection1String")
===============
change these code:
===============
Public Shared ReadOnly Property Connection1Connection As
ConnectionString
Get
Dim cs As ConnectionString = New ConnectionString()
Dim mdb =
System.IO.Path.Combine(System.Web.HttpContext.Current.Request.PhysicalApplic
ationPath,"intranet.mdb")
cs.Connection =
(System.Configuration.ConfigurationSettings.AppSettings("Connection1String")
).Replace("{db}", mdb)
===============
Step3:
publish project and it will be OK
Allen Kuo
> I try to set path in server for database but not...
> error is
> Parser Error Message: The '&' character, hexadecimal value 0x26, cannot
begin
> with a name. Line 19, position 99.
>
> Source Error:
>
>
> Line 17: <appSettings>
> Line 18:
> Line 19: <add key="Connection1String" value=
> "Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source=" &
> Server.MapPath("result.mdb") & ";Persist Security Info=False"
> Line 20: <add key="Connection1Type" value="OleDb"/>
> Line 21: <add key="Connection1Server" value="MSAccess"/>
>
> What is problem,
> thanks
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>
|
|
|
Allen
Posts: 2
|
Posted: 01/12/2006, 7:55 PM |
|
I post detail information(include C#,VB.NET,ASP, code and image), please reference: http://elearning.webapp.com.tw/ccs3/default.asp?url=/CCS3/ex_0050.asp
http://elearning.webapp.com.tw/ccs3/default.asp?url=/CCS3/ex_0051.asp
Maybe you can't read Chinese but you still can see images and code.
Allen Kuo
|
|
|