?
Solved

ASP link to sql database

Posted on 2013-07-01
6
Medium Priority
?
365 Views
Last Modified: 2013-07-09
Hi,

I'm new at ASP and just trying to hack at making some changes out of curiosity.

I have a ASP website that is referencing an access database. I converted the access database to a SQL database. I am trying to change my the link in my config page to connect to the SQL database. The SQL database is local.

AT the moment I have the following in my config.asp:
const DATABASE_FILE_PATH = "./db/NFL.mdb"

How can I change it so it points to my SQL database? The SQL database is called MyNFLPicks.

Any help would be appreciated.

IV
0
Comment
Question by:Ivano Viola
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 12

Expert Comment

by:duttcom
ID: 39291849
I am assuming you are talking about the web.config file rather than config.asp.

This is an example of a link to an SQL database in a web.config file -

  <connectionStrings>
    <add name="MyConnectionString" connectionString="Data Source=SERVERX;Initial Catalog=MyDatabase;Persist Security Info=True;User ID=sa;Password=password" providerName="System.Data.SqlClient"/>
</connectionStrings>

Open in new window


Then in the page that accesses the database, the SQL source used by the data control is -

        <asp:SqlDataSource ID="SqlSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:MyConnectionString %>" 
            SelectCommand="SELECT * FROM [TableInMyDatabase] ORDER BY [RecordID]">
        </asp:SqlDataSource>

Open in new window


May I suggest you dosnload a free copy of Visual Web Developer Express from Microsoft -

http://www.asp.net/downloads/essential

By using the tools in design mode, you can have Visual Studio step you through making these sorts of connections and hooking them up to data controls. This is a good way to learn asp.net, epsecially if you like to teach yourself.
0
 
LVL 21

Author Comment

by:Ivano Viola
ID: 39291893
This is actually classic ASP. The config file is named config.asp. The entry that connected the site to the database in the config.asp was:

const DATABASE_FILE_PATH = "./db/NFL.mdb"

from this.....not sure what is need to change the above string so it points to the SQL database.

IV
0
 
LVL 12

Expert Comment

by:duttcom
ID: 39291898
Sorry, my bad. Try this reference -

http://www.sqlstrings.com/sql-server-asp-conection.htm
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 11

Expert Comment

by:G_H
ID: 39292395
You do not mention explicitly which version of SQL you are using...

Whilst Microsoft would like to be thought of as owning SQL, SQL is actually a generic language, of which many providers make their own flavor.

I suspect that you are using MS-SQL rather than any of the the variants, but please let us know..

GH
(Go Raiders)
0
 
LVL 7

Accepted Solution

by:
dimmergeek earned 2000 total points
ID: 39308420
dim fso, rsObj

' Create the ADO connection object
set fso = CreateObject("ADODB.Connection")        

' Create recordsets
 set rsObj = Server.CreateObject("ADODB.Recordset")        

' Establish connection strings to priority report as well as the database tables
 fso.Open "Provider=SQLOLEDB;SERVER=PATH-TO-YOUR-DATABASE;DATABASE=DB-NAME;UID=USERNAME;PWD=PASSWORD"

Open in new window

0
 
LVL 7

Expert Comment

by:dimmergeek
ID: 39310961
Thanks!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

765 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