ASP link to sql database


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.

LVL 22
Ivano ViolaSystem AdministratorAsked:
Who is Participating?
dimmergeekConnect With a Mentor Commented:
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

Open in new window

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 -

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

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]">

Open in new window

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

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, epsecially if you like to teach yourself.
Ivano ViolaSystem AdministratorAuthor Commented:
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.

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Sorry, my bad. Try this reference -
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..

(Go Raiders)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.