Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dataConnect.asp - Is this written correctly?

Status
Not open for further replies.

neroe

Technical User
Feb 27, 2003
54
GB
Howdi,

First up any help with this would be greatly appreciated, thankyou.

I have written a small web site that uses VBScript and HTML to produce ASP which all operates through IIS on my XP Pro PC. The website also connects to an Access backend. It all works fine so I decided to take it a few steps further by getting it to operate in exactly the same way from a SQL backend. I have installed SQL 2000 successfully and also imported my database from Access into SQL successfully.

I also beleive that I have successfully established a webserver connection but wouldn't count on it.

(I tested the connection and it said it was successfull)

I would like to use a dataConnect.asp file as an include to those pages that need to make a connection to the database but I am not exactly sure of how this should be written.

So far my dataConnect.asp looks like this;

<%
adOpenStatic = 3
adOpenDynamic = 2
adLockReadOnly = 1
adOpenForwardOnly = 0
adLockOptimistic = 3
adUseClient = 3
strConncar = &quot;Provider=SQLOLEDB.1; Password=; Persist Security Info=True; User ID=sa; Initial Catalog=webmonkey; Data Source=amdoneg&quot;
function makeConnection()
set makeConnectionconncar = server.CreateObject(&quot;ADODB.Connection&quot;)
makeConnectionconncar.connectionString = strConncar
makeConnectionconncar.open
end function
%>

To connect to the Access database (in the Access version of the site) the code looks like this;

<%
Cars table.
SQLCAR=&quot;SELECT carName, carID FROM Cars&quot;
set conncar = server.createobject(&quot;ADODB.Connection&quot;)
conncar.open &quot;parking&quot;
set cars=conncar.execute(SQLCAR)
%>

How do I merge the two?

I also need to know what bit of VBScript must go at the top of the pages that need to make the connection.

I know that it should look something like this but not exactly how.

<%
set objConn = makeConnection()
set rstEvents = Server.CreateObject(&quot;ADODB.Recordset&quot;)
%>

Bits of code like the piece above have been extracted from another source so please excuse them for looking well out of place.

I am willing to mail any of the code as I appreciate that it is difficult to help sometimes without viewing &quot;the bigger picture&quot;

Thanks alot,
neroe
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top