Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
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 January 9th, 2008, 08:13 AM
Authorized User
Points: 136, Level: 2
Points: 136, Level: 2 Points: 136, Level: 2 Points: 136, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2006
Location: London Town, , United Kingdom.
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default Connection Error

G'day..

I've been charged with the task of continuing the development of an ASP site, I've copied it down to the Dev server and created the DB structure etc. Problem is I'm having trouble connecting to the DB? The site previously had no Global.asa file, so have created one with the connection string as below:

Dim CONNECTION_STRING
CONNECTION_STRING = "Data Source=COMPUTERNAME\SQLEXPRESS;Initial Catalog=SomeDB;Integrated Security=True"

It seems that when each page is loaded, it makes the connection at the top of the page, which is then used by several commands in that page:

<%
Dim oDBConn
Set oDBConn = Server.CreateObject("ADODB.Connection")
oDBConn.Open CONNECTION_STRING
%>

Trouble is, I'm getting the following error:

Error Type:
Microsoft OLE DB Service Components (0x80040E21)
Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.
/Search.asp, line 5

Any ideas what I'm doing wrong??

Hasta Luego..
KingRoon

DogFightClothing. No dogs. No fighting.
http://www.dogfightclothing.com
__________________
Hasta Luego..
KingRoon

DogFightClothing. No dogs. No fighting.
http://www.dogfightclothing.com
 
Old January 9th, 2008, 08:09 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

Matt

Is there any reason you have the connection string in a global.asa file? A good reason maybe to place a session based hit counter, extend the script time out, LCID so your application renderes dated in the dd/mm/yyyy Aussie format (the syntax for aussie is Session.LCID = 3081) or the like. IMO if its just for connecting for general web pages its not a good place to put it.

Interesting I never seen your error.

Anyhow one of many ways to skin a cat, here is how I connect:

1.create a global.asp file (in my scripts directory). This file holds things like constants, commonly dim'ed variables and the like:

  dim conn,sql,EoF,...
  const IUSER = "DBUsername"
  const PWord = "DBPassword"
  const DBNAME = "myDataBaseName"
  const DBSERVER = "myComputerName"
  const URLBase = "http://someDomainName/ohs/"
  const DOCBase = "http://someDomainName/ohs/DocPages/Docs/"

Then I create a functions.asp file (in my scripts directory). This holds ALL of my functions including the connection string(the variables used in the connection string as seen above are held in the global.asp file so there is never a need to change the connection sting in the functions file):

  Function GetConnectionString()
     GetConnectionString = "Provider=SQLOLEDB.1; Password=" & pWord & "; Persist Security Info=True; User ID=" & IUSER & "; Initial Catalog=" & DBNAME & "; Data Source=" & DBSERVER & ";"
  End Function

Now when you want a connection on any web page place this at the top of the page:

<% OPTION EXPLICIT %>


<% Set Conn = server.createobject("ADODB.Connection")
     conn.open(GetConnectionString)

not a solution to your specific problem however its the way I connect and have done for years. All you need to change is the values held against the constants in the global.asp file for it to work.

I see you are in Sydney, we are very close...

Wind is your friend
Matt
www.elitemarquees.com.au
 
Old January 10th, 2008, 11:00 AM
Authorized User
Points: 136, Level: 2
Points: 136, Level: 2 Points: 136, Level: 2 Points: 136, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2006
Location: London Town, , United Kingdom.
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hey Matt,

Thanks for the reply mate, I tend to hold all App data in my Global.asa such as connection strings etc. Is this a bad idea? And thanks for the tip on the LCID, but I've moved to London [I gotta update my profile!] for a coupla years to earn the Sterling ;o)

Believe it or not the problem was in the SQL Server Express instance of my DB.. Sorted the connection string to:

 "Provider=SQLOLEDB;Data Source=COMPUTER_NAME\SQLEXPRESS;Initial Catalog=SomeDB;Integrated Security=SSPI;"

and, having sorted the guest role, bingo.. Anyways, thanks for your reply and work around, it's always good to see different ways of doing something eh.

Only been here a coupla months and missing Sydney already..

Hasta Luego..
KingRoon

DogFightClothing. No dogs. No fighting.
http://www.dogfightclothing.com
 
Old January 10th, 2008, 08:48 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

No worries happy to try n help - this forum has helped me a great deal over the years...

I dont think its a bad idea. I only use a global.asa file if I need to, probably only 20% of systems I build need this file. My post was a bit verbose you might say. Things are slow here in the first week of 08 so I am spending a bit of time here helping others where I can in appreciation for the forum being so good to me over the years.

Im sure Sydney's missing you to...

Wind is your friend
Matt
www.elitemarquees.com.au




Similar Threads
Thread Thread Starter Forum Replies Last Post
Connection Error asters .NET Framework 1.x 3 April 4th, 2008 12:46 AM
Connection Error zaghmout ASP.NET 2.0 Professional 3 October 31st, 2007 01:55 AM
connection error jigsy ADO.NET 1 May 22nd, 2007 08:00 AM
connection error janees ASP.NET 2.0 Professional 1 March 2nd, 2007 02:26 PM
Connection Error: Please Help code_lover ADO.NET 3 February 6th, 2007 10:12 PM





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