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 July 18th, 2003, 08:38 AM
Authorized User
 
Join Date: Jun 2003
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default Connection String with VB and Java

I have a site with several ASP enabled pages that all access the same SQL Server database. Some of the scripts are writen in JavaScript others are writtend with VBScript.

When the site used all one language I used to have a function definition in an include file that would take a connection object as a parameter and connect it to my database. Then if anything about the server changed, I could change it in one place and be done with it.

Unfortunately now that there is not a consistent language across our site I can't write a function definition that will work for all pages. I've tried doing something like:

<% ...
conn.Open %><%
...%>

but it only works with JavaScript not in VBScript.

I'm fairly new with web programming, does anyone know how I could store my connection string in just 1 file and still access it easily from both languages?
 
Old July 18th, 2003, 09:46 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

in your include file you could make it a function called maybe GetConnectionString, that returns the connection string. Then in your code you would do:

<%...
conn.Open GetConnectionString()
..%>
that should work from both languages.
 
Old July 18th, 2003, 10:09 AM
Authorized User
 
Join Date: Jun 2003
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The problem is VB and Java define functions differently.

1) Java encloses the body of the function in curly braces while VB uses an End Function keyword.
2) Java uses the return keyword while VB uses [function name] = [return value]

So unfortunately I cannot write 1 function for both languages. What I really need is a way to initialize a variable to the contents of a file. Maybe access the file via the script itself with a file object? Would this be a bad way of going about it?

Thanks,
Mike





Similar Threads
Thread Thread Starter Forum Replies Last Post
Java MySql Connection ruzdi Java Basics 21 May 14th, 2012 12:57 AM
Connection string MunishBhatia ASP.NET 2.0 Professional 4 May 16th, 2007 05:50 AM
connection string nalla ASP.NET 1.0 and 1.1 Professional 2 January 23rd, 2006 04:03 AM
Connection String JsonTerre1 BOOK: ASP.NET Website Programming Problem-Design-Solution 5 November 1st, 2004 02:06 AM
Connection String fs22 Classic ASP Databases 3 August 30th, 2004 01:25 AM





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