|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Relative path to Access database in .net 2displaying the retrieved data with a DataList, in asp.net 2. I want to use a relative path to the .MDB file. However, I get this error: "The connection name was not found in the applications configuration or the connection string is empty" The .aspx file: <asp:SqlDataSource ID="DataSourceLinks" runat="server" ConnectionString="<%$ ConnectionStrings:DBforbLinks %>" ProviderName="System.Data.Odbc" SelectCommand="SELECT blah FROM blah"> </asp:SqlDataSource> <asp:DataList ID="DataList1" runat="server" DataSourceID="DataSourceLinks"> </asp:DataList> The web.config file: <appSettings> <connectionStrings> <add name="DBForbLinks" connectionString="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=~/myFolder/myDB.mdb" providerName="System.Data.OleDb" /> </connectionStrings> </appSettings> I've removed all the styling-code etc. in the above code. So, what's wrong? -- Regards, Thomas Hi Thomas,
In connection string, Data Source value should be a physical path rather than a virtual path. HTH Elton Wang Show quote "Thomas M" wrote: > I'm trying to read from an Access database using an SqlDataSource and > displaying the retrieved data with a DataList, in asp.net 2. > I want to use a relative path to the .MDB file. > However, I get this error: > "The connection name was not found in the applications configuration > or the connection string is empty" > > The .aspx file: > <asp:SqlDataSource ID="DataSourceLinks" runat="server" > ConnectionString="<%$ ConnectionStrings:DBforbLinks %>" > ProviderName="System.Data.Odbc" SelectCommand="SELECT blah > FROM blah"> > </asp:SqlDataSource> > > <asp:DataList ID="DataList1" runat="server" > DataSourceID="DataSourceLinks"> > </asp:DataList> > > The web.config file: > <appSettings> > <connectionStrings> > <add name="DBForbLinks" > connectionString="Provider=Microsoft.Jet.OLEDB.4.0; Data > Source=~/myFolder/myDB.mdb" > providerName="System.Data.OleDb" /> > </connectionStrings> > </appSettings> > > I've removed all the styling-code etc. in the above code. > > So, what's wrong? > > -- > Regards, > Thomas > > On Sun, 22 Jan 2006 13:21:02 -0800, "Elton W"
<Elt***@discussions.microsoft.com> wrote: >In connection string, Data Source value should be a physical path rather Hi Elton.>than a virtual path. I want to use a relative path, because the path to the database differ between my development workstation and the production server. -- Regards, Thomas M On Mon, 23 Jan 2006 07:44:07 +0100, Thomas M <tma***@fjernesvip.cybercity.dk> wrote:
¤ On Sun, 22 Jan 2006 13:21:02 -0800, "Elton W" ¤ <Elt***@discussions.microsoft.com> wrote: ¤ ¤ >In connection string, Data Source value should be a physical path rather ¤ >than a virtual path. ¤ ¤ Hi Elton. ¤ ¤ I want to use a relative path, because the path to the database differ ¤ between my development workstation and the production server. You can't use a relative path in the connection string. You must build the complete physical path, which you should be able to do based upon your application location or config file setting. Paul ~~~~ Microsoft MVP (Visual Basic)
Other interesting topics
|
|||||||||||||||||||||||