Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. 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 Databases 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 August 12th, 2005, 07:56 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Adam H-W
Default Problem with connection string

Hi there

I'm trying to connect to an MS SQL Server db on one server with my asp files on another server. This I can do fine using an include file with the following code:

<%
    Set con = Server.CreateObject("ADODB.Connection")

    con.Open = "Provider=SQLOLEDB; Data Source = 100.100.100.100; Initial Catalog = db_golf; User Id = db_user; Password=123456"

%>

All details in the above are fictitious! However on some of my asp pages I want to make some changes to the database - either editing or adding etc and I use the following code for this:

set rs = server.createobject("ADODB.Recordset")
    rs.open "SELECT * FROM Fixtures", Application("golf_ConnectionString"), 1, 3

    rs.AddNew()

etc etc

but what I'm stuck on is what I need to change the Application("golf_ConnectionString") to -

do I need to add some code to the include file so that it knows what
("golf_ConnectionString") is??

Many thanks

Adam

 
Old August 12th, 2005, 09:11 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

Adam!!

Stmt1> rs.open "SELECT * FROM Fixtures", Application("golf_ConnectionString"), 1, 3

the connection string made by above in ur case(con.Open = "Provider=SQLOLEDB; Data Source = 100.100.100.100; Initial Catalog = db_golf; User Id = db_user; Password=123456" )

wont reflect "Stmt1" ,because it is using connection string from application variable.

if you want to use ur newly created connection string
then u must pass it to rs.open method to reflect

Other alternative is that u can lock the application varaible and set the new connection string ,then unlock it

Hope this will help you






Cheers :)

vinod
 
Old August 12th, 2005, 09:20 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Adam H-W
Default

Hi Vinod

thanks for your reply which is much appreciated.

That's exactly it - I need to pass the new connection string to the rs.open method but I'm not sure how to do it - i.e the syntax etc. Can you help?

Thanks in anticipation

Adam

 
Old August 12th, 2005, 11:51 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

<%
    Set con = Server.CreateObject("ADODB.Connection")

    con.Open "Provider=SQLOLEDB; Data Source = 100.100.100.100; Initial Catalog = db_golf; User Id = db_user; Password=123456"


set rs = server.createobject("ADODB.Recordset")
    rs.open "SELECT * FROM Fixtures",con , 1, 3
%>
http://www.w3schools.com/ado/ado_display.asp

http://psacake.com/web/ho.asp
hope this will help you

Cheers :)

vinod





Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with SQL SERVER Connection String Non Linear BOOK: Beginning ASP 3.0 3 October 20th, 2005 12:35 AM
Connection string problem neo_jakey Beginning VB 6 1 October 10th, 2004 12:24 AM
Problem with the connection string?? budman Access ASP 2 March 29th, 2004 07:12 AM
connection string aadz5 ASP.NET 1.0 and 1.1 Basics 4 October 20th, 2003 08:43 AM
connection string problem mateenmohd SQL Server 2000 2 September 3rd, 2003 01:41 PM





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