Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 11th, 2005, 11:24 PM
Registered User
 
Join Date: Apr 2005
Posts: 352
Thanks: 14
Thanked 0 Times in 0 Posts
Send a message via Yahoo to rupen
Default Changing Database.

Okay, I am using MS Access as backend righ-now, there is a change that i may have to change it to SQL Server after some time, so can anyone let me know which codepart I have to change while changing DB, OR how to write DB independent ASP code.


 
Old July 11th, 2005, 11:38 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

SQL Server is an enterprize data store, Access is not. You are better off going to SQL sooner than later for many many reasons, scaleability being the number one.

;;;which codepart I have to change while changing DB
Your connection string is all you need to change. It should look something like:
Provider=SQLOLEDB.1; Password=aPassword; Persist Security Info=True; User ID=aUserName; Initial Catalog=aDBName; Data Source=pcName;

;;;how to write DB independent ASP code
ASP code is DB independent

Moving from Access to SQL is very easy. When you get SQL installed look at the DTS tool. There are differences in datatypes and a few other things to be aware of.

Wind is your friend
Matt
 
Old July 12th, 2005, 03:13 AM
Registered User
 
Join Date: Apr 2005
Posts: 352
Thanks: 14
Thanked 0 Times in 0 Posts
Send a message via Yahoo to rupen
Default

Right now i am using Recordset.AddNew method to Add new record, I heard that It won't work if i change DB, so better to write objConnection.Execute "inset into..", is it true? Can you focus on this?
Thanks in Advance.

 
Old July 12th, 2005, 06:02 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

I dont use this method so im not sure, what do I do in every page I need a database connection:
<% OPTION EXPLICIT %>


<% Set Conn = server.createobject("ADODB.Connection")
     conn.open(GetConnectionString)
     'an insert
     sql = "INSERT INTO..."
     conn.execute(sql)
     'an select
     sql = "SELECT..."
     set rsName = conn.execute(sql)
%>


In you global.asp file place all your constants etc:
   const IUSER = "un"
   const pWord = "pw"
   const DBNAME = "db"
   const DBSERVER = "aPcName"

In your functions.asp place all your functions including your connection string:
  GetConnectionString = "Provider=SQLOLEDB; Password=" & PASS & "; Persist Security Info=True; User ID=" & IUSER & ";Initial Catalog=" & DBNAME & "; Data Source=" & DBSERVER
  End Function

Now all you need to do when chnaging DBs is change one line in your functions.asp file





Wind is your friend
Matt





Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing database at runtime joerage BOOK: Professional Crystal Reports for VS.NET 3 December 15th, 2006 05:55 PM
changing the way a database stored value is output red_fiesta Classic ASP Professional 1 November 15th, 2006 05:46 AM
Changing Database for Crystal Reports pavel Pro VB 6 4 December 5th, 2005 01:58 PM
Changing Datatype In Access Database fastcorvette Pro VB 6 9 October 8th, 2003 11:57 AM
Changing Datatype In Access Database fastcorvette Access 2 October 8th, 2003 11:53 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.