| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||||
|
|||||
|
Connection String Function
Here's a shortcut function I created for three common databases. You can add to it or modify it to your needs.
The correct syntax would be: Code:
Conn.Open = SQLConnect("Type of Database (1, 2, or 3)", "Localhost, Server, or DB Path", "Database Name", "User ID for database", "Password for database")
ASP Code:
__________________
www.xoise.com - www.ourfreegames.com - www.playtouchgames.com - www.randomtools.net - www.xenocide-rpg.com |
|
#2
|
||||
|
||||
|
And if you're really lazy, I've created it with one string, seperated my commas which are split into an array and used
(I'm lazy )Code:
Example
SQLConnect("1,localhost,My_Database,Username,Password")
Code:
Function
Function SQLConnect(arrX)
arrX = Split(arrX,",")
If arrX(0) = 1 Then
SQLConnect = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=" & arrX(1) & ";DATABASE=" & arrX(2) & ";UID=" & arrX(3) & ";PWD=" & arrX(4) & ";OPTION=3;"
ElseIf intType = 2 Then
SQLConnect = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & arrX(1) & ";UID=" & arrX(3) & ";PWD=" & arrX(4) & ";"
Else
SQLConnect = "DRIVER={SQL Server};SERVER=" & arrX(1) & ";DATABASE=" & arrX(2) & ";UID=" & arrX(3) & ";PWD=" & arrX(4) & ";"
End If
End Function
|
|
#3
|
||||
|
||||
|
lol nice trick!
![]() |
![]() |
| Viewing: ASP Free Forums > Programming > Code Bank > Connection String Function |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|