FrontPage Convert From ODBC (Full Version)

All Forums >> [Web Development] >> ASP and Database



Message


Spooky -> FrontPage Convert From ODBC (7/22/2005 12:18:20)

You are best to use an OLEDB connection when accessing databases via FP
However - the default is an ODBC connection.

Some versions of the global.asa file include a conversion, but some dont.
Here is the code that you can include in the global.asa file.

To action the sub, there should be a call in the OnStart sub like so :

Sub Session_OnStart
FrontPage_ConvertFromODBC
End Sub


Sub FrontPage_ConvertFromODBC
	On Error Resume Next
	if Len(Application("ASP_OS")) > 0 then exit sub
	str = "_ConnectionString"
	slen = Len(str)
	set oKnown = Server.CreateObject("Scripting.Dictionary")
	oKnown.Add "DRIVER",""
	oKnown.Add "DBQ",""
	oKnown.Add "SERVER",""
	oKnown.Add "DATABASE",""
	oKnown.Add "UID",""
	oKnown.Add "PWD",""
	Application.Lock
	For each item in Application.Contents
		if UCase(Right(item,slen)) = UCase(str) then
			sName = Left(item,Len(item)-slen)
			sConn = Application(item)
			if InStr(LCase(sConn),"provider=") < 1 and Len(Application(sName & "_ConnectionTimeout"))>0 then
				sArr = Split(sConn,";")
				set oDict = Server.CreateObject("Scripting.Dictionary")
				bUnknown = False
				for i = 0 to UBound(sArr)
					s = sArr(i)
					idx = InStr(s,"=")
					sKey = UCase(Trim(Left(s,idx-1)))
					sVal = Trim(Mid(s,idx+1))
					oDict.Add sKey, sVal
					if Not oKnown.Exists(sKey) then bUnknown = True
				next
				if bUnknown = False and oDict.Exists("DRIVER") then
					sDrv = oDict.Item("DRIVER")
					sNew = ""
					if InStr(sDrv,"Microsoft Access") > 0 and oDict.Exists("DBQ") and not (oDict.Exists("UID") or oDict.Exists("PWD")) then
						sNew = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & oDict.Item("DBQ")
					elseif InStr(sDrv,"SQL Server") > 0 and oDict.Exists("SERVER") and oDict.Exists("DATABASE") then
						sNew = "Provider=SQLOLEDB;Data Source=" & oDict("SERVER") & ";Initial Catalog=" & oDict("DATABASE")
						if oDict.Exists("UID") then sNew = sNew & ";User ID=" & oDict("UID")
						if oDict.Exists("PWD") then sNew = sNew & ";Password=" & oDict("PWD")
					end if
					if sNew <> "" then
						Application(item) = sNew
					end if
				end if
				set oDict = Nothing
			end if
		end if
	Next
	Application.Unlock
	Set oKnown = Nothing
End Sub




maltina1 -> RE: FrontPage Convert From ODBC (8/2/2006 5:28:32)


quote:

ORIGINAL: Spooky

You are best to use an OLEDB connection when accessing databases via FP
However - the default is an ODBC connection.

Some versions of the global.asa file include a conversion, but some dont.


I have taken your advise.I checked if my global include the conversion.And it does.The code is exactly as you have quoted above.I have used DIW for the creation of the forms.But on the other machines it works,except on this server.

Thanks for your response




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.046875