Access database - Connection String

Visual Studio Connection String and web Config file

Page 1 of 1

2 Replies - 5866 Views - Last Post: 17 May 2009 - 11:52 PM Rate Topic: -----

#1 Blancoh  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 08-May 09

Access database - Connection String

Posted 17 May 2009 - 12:58 AM

I am trying to help a guy who has an old website written in classic asp.

I have used visual studio to generate gridview reports from access database on my IIS where the directory is hard coded in the connection string, that the wizards used to create the connection string.

when i went to move the code to the web hosting site - how do i point the connection string at the virtual directory on the web hosting site.

I need to change the web.config file to use severmap.mappath - but this did not seem to work.

How can I change the generated visual studio code to pick up the correct path.

[visual studio generated string]
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:SearchwebaddressesConnectionString %>"
ProviderName="<%$ ConnectionStrings:SearchwebaddressesConnectionString.ProviderName %>"
SelectCommand="SELECT [Emailid1], [Email_Addresses], [DateE] FROM [xxxxx] WHERE ([xxxx] LIKE '%' + ? + '%')">
<SelectParameters>
<asp:ControlParameter ControlID="EmailSrch" Name="xxxx"
PropertyName="Text" Type="String" />
</SelectParameters>
</asp:SqlDataSource>

Web Config entry
<connectionStrings>
<add name="SearchwebaddressesConnectionString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\webaddresses.mdb"
providerName="System.Data.OleDb" />
[/visual studio generated string]

Help appreciated.

Is This A Good Question/Topic? 0
  • +

Replies To: Access database - Connection String

#2 noorahmad  Icon User is offline

  • Untitled
  • member icon

Reputation: 209
  • View blog
  • Posts: 2,290
  • Joined: 12-March 09

Re: Access database - Connection String

Posted 17 May 2009 - 01:03 AM

:code:
Was This Post Helpful? 0
  • +
  • -

#3 newProgram  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 160
  • Joined: 28-October 08

Re: Access database - Connection String

Posted 17 May 2009 - 11:52 PM

View PostBlancoh, on 16 May, 2009 - 11:58 PM, said:

I am trying to help a guy who has an old website written in classic asp.

I have used visual studio to generate gridview reports from access database on my IIS where the directory is hard coded in the connection string, that the wizards used to create the connection string.

when i went to move the code to the web hosting site - how do i point the connection string at the virtual directory on the web hosting site.

I need to change the web.config file to use severmap.mappath - but this did not seem to work.

How can I change the generated visual studio code to pick up the correct path.

[visual studio generated string]
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:SearchwebaddressesConnectionString %>"
ProviderName="<%$ ConnectionStrings:SearchwebaddressesConnectionString.ProviderName %>"
SelectCommand="SELECT [Emailid1], [Email_Addresses], [DateE] FROM [xxxxx] WHERE ([xxxx] LIKE '%' + ? + '%')">
<SelectParameters>
<asp:ControlParameter ControlID="EmailSrch" Name="xxxx"
PropertyName="Text" Type="String" />
</SelectParameters>
</asp:SqlDataSource>

Web Config entry
<connectionStrings>
<add name="SearchwebaddressesConnectionString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\webaddresses.mdb"
providerName="System.Data.OleDb" />
[/visual studio generated string]

Help appreciated.

change your connection string in Web.config
<connectionString>
<add name="SearchwebaddressesConnectionString" connectionString="Password=<password>;Persist Security Info=True;User ID=<user_id>;Initial Catalog=<db_name>;Data Source=<db_location>" providerName="System.Data.OleDb" />
</connectionString>


Note that the Data Source is the location of your db. You may put the IP Address of the machine where the DB is located. If the DB is in the same machine just put localhost in it.

This post has been edited by newProgram: 17 May 2009 - 11:53 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1