I am having trouble with a connection string that I use to connect to several different db's. It is strange because I use the same string on numerous pages and it works on some, but not on a couple. I get a type mismatch error within the following code:
coachdan32
Code:
If varBusName = "Citi" Then
If varYrA = "2002" Then
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & Server.Mappath("Training_Delivery_Data.mdb") & ";"
SQLAdd = " SELECT * FROM TrainersAU "
Set uRS = Server.CreateObject("ADODB.Recordset")
uRS.Open SQLAdd, Connect, adOpenKeyset,adLockOptimistic
End If
If varYrA = "2003" Then
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & Server.Mappath("Training_Delivery_Data03.mdb") & ";"
SQLAdd = " SELECT * FROM TrainersAU "
Set uRS = Server.CreateObject("ADODB.Recordset")
uRS.Open SQLAdd, Connect, adOpenKeyset,adLockOptimistic
End If
If varYrA = "2004" Then
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & Server.Mappath("Training_Delivery_Data04.mdb") & ";"
SQLAdd = " SELECT * FROM TrainersAU "
Set uRS = Server.CreateObject("ADODB.Recordset")
uRS.Open SQLAdd, Connect, adOpenKeyset,adLockOptimistic
End If
If varYrA = "2005" Then
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & Server.Mappath("Training_Delivery_Data05.mdb") & ";"
SQLAdd = " SELECT * FROM TrainersAU "
Set uRS = Server.CreateObject("ADODB.Recordset")
uRS.Open SQLAdd, Connect, adOpenKeyset,adLockOptimistic
End If
If varYrA = "2006" Then
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & Server.Mappath("Training_Delivery_Data06.mdb") & ";"
SQLAdd = " SELECT * FROM TrainersAU "
Set uRS = Server.CreateObject("ADODB.Recordset")
uRS.Open SQLAdd, Connect, adOpenKeyset,adLockOptimistic
End If
If varYrA = "2007" Then
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & Server.Mappath("Training_Delivery_Data07.mdb") & ";"
SQLAdd = " SELECT * FROM TrainersAU "
Set uRS = Server.CreateObject("ADODB.Recordset")
uRS.Open SQLAdd, Connect, adOpenKeyset,adLockOptimistic
End If
If varYrA = "2008" Then
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & Server.Mappath("Training_Delivery_Data08.mdb") & ";"
SQLAdd = " SELECT * FROM TrainersAU "
Set uRS = Server.CreateObject("ADODB.Recordset")
uRS.Open SQLAdd, Connect, adOpenKeyset,adLockOptimistic
End If
If varYrA = "2009" Then
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & Server.Mappath("Training_Delivery_Data09.mdb") & ";"
SQLAdd = " SELECT * FROM TrainersAU "
Set uRS = Server.CreateObject("ADODB.Recordset")
uRS.Open SQLAdd, Connect, adOpenKeyset,adLockOptimistic
End If
If varYrA = "2010" Then
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & Server.Mappath("Training_Delivery_Data10.mdb") & ";"
SQLAdd = " SELECT * FROM TrainersAU "
Set uRS = Server.CreateObject("ADODB.Recordset")
uRS.Open SQLAdd, Connect, adOpenKeyset,adLockOptimistic
End If
Else
If varYrA = "2002" Then
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & Server.Mappath("Training_Delivery_DataSears.mdb") & ";"
SQLAdd = " SELECT * FROM TrainersAU "
Set uRS = Server.CreateObject("ADODB.Recordset")
uRS.Open SQLAdd, Connect, adOpenKeyset,adLockOptimistic
End If
If varYrA = "2003" Then
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & Server.Mappath("Training_Delivery_Data03Sears.mdb") & ";"
SQLAdd = " SELECT * FROM TrainersAU "
Set uRS = Server.CreateObject("ADODB.Recordset")
uRS.Open SQLAdd, Connect, adOpenKeyset,adLockOptimistic
End If
If varYrA = "2004" Then
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & Server.Mappath("Training_Delivery_Data04Sears.mdb") & ";"
SQLAdd = " SELECT * FROM TrainersAU "
Set uRS = Server.CreateObject("ADODB.Recordset")
uRS.Open SQLAdd, Connect, adOpenKeyset,adLockOptimistic
End If
If varYrA = "2005" Then
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & Server.Mappath("Training_Delivery_Data05Sears.mdb") & ";"
SQLAdd = " SELECT * FROM TrainersAU "
Set uRS = Server.CreateObject("ADODB.Recordset")
uRS.Open SQLAdd, Connect, adOpenKeyset,adLockOptimistic
End If
If varYrA = "2006" Then
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & Server.Mappath("Training_Delivery_Data06Sears.mdb") & ";"
SQLAdd = " SELECT * FROM TrainersAU "
Set uRS = Server.CreateObject("ADODB.Recordset")
uRS.Open SQLAdd, Connect, adOpenKeyset,adLockOptimistic
End If
If varYrA = "2007" Then
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & Server.Mappath("Training_Delivery_Data07Sears.mdb") & ";"
SQLAdd = " SELECT * FROM TrainersAU "
Set uRS = Server.CreateObject("ADODB.Recordset")
uRS.Open SQLAdd, Connect, adOpenKeyset,adLockOptimistic
End If
If varYrA = "2008" Then
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & Server.Mappath("Training_Delivery_Data08Sears.mdb") & ";"
SQLAdd = " SELECT * FROM TrainersAU "
Set uRS = Server.CreateObject("ADODB.Recordset")
uRS.Open SQLAdd, Connect, adOpenKeyset,adLockOptimistic
End If
If varYrA = "2009" Then
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & Server.Mappath("Training_Delivery_Data09Sears.mdb") & ";"
SQLAdd = " SELECT * FROM TrainersAU "
Set uRS = Server.CreateObject("ADODB.Recordset")
uRS.Open SQLAdd, Connect, adOpenKeyset,adLockOptimistic
End If
If varYrA = "2010" Then
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & Server.Mappath("Training_Delivery_Data10Sears.mdb") & ";"
SQLAdd = " SELECT * FROM TrainersAU "
Set uRS = Server.CreateObject("ADODB.Recordset")
uRS.Open SQLAdd, Connect, adOpenKeyset,adLockOptimistic
End If
End If
coachdan32