Solved

Cursorlocation property - adUseclient undefined error

Posted on 2004-04-20
14
1,809 Views
Last Modified: 2012-08-13
Hi experts,
               i have a login form(loginform.asp) and when i click on the login form by giving password and username it is giving the following error as

                Variable is undefined: 'adUseClient'
/AFI-Agents/include_io/io_support_page.asp, line 45

The code in line 45 is objConn.CursorLocation=adUseClient.

Can anyone tell me how to correct this error and display my form(mainform.asp).

Any questions,comments and furthur readings are welcome.


Thanks in advance

0
Comment
Question by:pradeepy
  • 9
  • 5
14 Comments
 
LVL 31

Expert Comment

by:alorentz
ID: 10873628
You either need to include this file in the ASP: adovbs.inc

OR use the nuber for cursor location:

 objConn.CursorLocation=1
0
 
LVL 31

Expert Comment

by:alorentz
ID: 10873634
Here are the numbers:

adUseNone -1- OBSOLETE (appears only for backward compatibility). Does not use cursor services
adUseServer- 2 -Default. Uses a server-side cursor
adUseClient -3- Uses a client-side cursor supplied by a local cursor library. For backward compatibility, the synonym adUseClientBatch is also supported

So you would use:

objConn.CursorLocation=3

0
 
LVL 31

Expert Comment

by:alorentz
ID: 10873642
0
 

Author Comment

by:pradeepy
ID: 10873692
Hi alorentz,

  i have corrected the code to objConn.CursorLocation=3, but now when iam connecting to database iam getting the following error

Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
/AFI-Agents/include_io/io_support_page.asp, line 62

Can you please let me know how to correct this error also.

Thanks in advance


0
 
LVL 31

Expert Comment

by:alorentz
ID: 10873836
I'm guessing you are using the Microsoft Access driver, but you should use the OLEDB Jet driver.

http://www.able-consulting.com/MDAC/ADO/Connection/OLEDB_Providers.htm#OLEDBProviderForMicrosoftJet

oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\somepath\myDb.mdb;"
0
 
LVL 31

Expert Comment

by:alorentz
ID: 10873862
Either way:

Post the code block for the connection and query...
0
 

Author Comment

by:pradeepy
ID: 10873921

Hi alorentz,
the code is as shown below iam using SQL Server

Application("sta_Connect_String") = "Provider=SQLOLEDB; Data Source=JDP01DB0609; Initial Catalog=AFIAgents; User ID=PK3_Operator; Password=pk2allaccess".

The full code ia as shown below
------------------------------------

Sub Application_OnStart
                Application.Lock
                  Application("staSite_Name")                   = "afiagents"
                  Application("staApp_Root")                   = "http://localhost/afi-agents"
' Production....ish
'                  Application("staJAG_Connect_String")  = "Provider=SQLOLEDB; Data Source=EGGHEAD; Initial Catalog=PKJaguar; User ID=PK2_Operator; Password=pk2allaccess"
'    Centex Dev database
'                  Application("staJAG_Connect_String") = "Provider=SQLOLEDB; Data Source=EGGHEAD; Initial Catalog=PKJaguar;    User ID=PK2_Operator; Password=pk2allaccess"
                  'Existing connection string
'                  Application("sta_Connect_String") = "Provider=SQLOLEDB; Data Source=JDP01DB0609; Initial Catalog=PKJaguar; User ID=PK2_Operator; Password=pk2allaccess"
                  ''Application("sta_Connect_String") = "Provider=SQLOLEDB; Data Source=JDP01DB0609; Initial Catalog=AFIClaims; User ID=PK3_Operator; Password=pk2allaccess"
                  Application("sta_Connect_String") = "Provider=SQLOLEDB; Data Source=JDP01DB0609; Initial Catalog=AFIAgents; User ID=PK3_Operator; Password=pk2allaccess"
                  Application("staReport_Folder")="Pregenrpt/"
            Application.Unlock
                  'strConn = "DRIVER={Microsoft ODBC for Oracle}; SERVER=DatabaseAlias; UID=UserID; PWD=Password
    End Sub


    Sub Session_OnStart

            Dim strCurrent_Page, strLogin_Form, strKU_Login, strTimed_Out_Page
            Dim strMain_Frameset_Page
            
            strLogin_Form = "/" & Application("staSite_Name") & "/loginForm.asp"
            strTimed_Out_Page = "/" & Application("staSite_Name") & "/timed_out_page.asp"
            strMain_Frameset_Page = "/" & Application("staSite_Name") & "/main_frameset.asp"

            strCurrent_Page = Request.ServerVariables("SCRIPT_NAME")
            If UCase(Trim(strCurrent_Page & "")) = UCase(strLogin_Form)  Or _
               UCase(Trim(strCurrent_Page & "")) = UCase(strTimed_Out_Page) Or _
               UCase(Trim(strCurrent_Page & "")) = UCase(strMain_Frameset_Page) Then
                  Exit Sub
            End if
   
    End Sub
Thanks in advance
 
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 31

Expert Comment

by:alorentz
ID: 10873974
Ohhh....SQL Server huh.  What line is causing the error, or where is it occuring.  Can you get a connection to work at all anywhere?
0
 

Author Comment

by:pradeepy
ID: 10874260

Hi
it is showing error on line 5

 Sub Application_OnStart
1.) Application.Lock
2.)Application("staSite_Name")                   = "AFI-Agents"
3.)Application("staApp_Root")      = "http://localhost/AFI-Agents"
4.)Password=pk2allaccess"
5.)Application("sta_Connect_String") = "Provider=SQLOLEDB; Data Source=JDP01DB0609; Initial Catalog=AFIClaims; User ID=PK3_Operator; Password=pk2allaccess"

6.)Application("staReport_Folder")="Pregenrpt/"
7.)Application.Unlock
            
    End Sub
0
 
LVL 31

Expert Comment

by:alorentz
ID: 10874352
That's not possible to have an error there?  You are just assigning an Application variable.  Are you sure that is where the error is?

This would cause an error if anything:

4.)Password=pk2allaccess"  '<-----------extra quote
0
 

Author Comment

by:pradeepy
ID: 10874421

Hi sorry the page is showing error on line 8

Function gmOpen_Connection(objADO, objConn, strMod_Name)

      Dim sConn_String, sql, strMsg, strApp_Var      
      strApp_Var = "sta_Connect_String"
sConn_String =gmGet_App_State(strApp_Var, "String") 'gmGet_App_State(strApp_Var, "String")
      Err.clear
      Set objConn = Server.CreateObject("ADODB.Connection")
      objConn.CursorLocation = 3
      
      If Err.Number <> 0 then
            strMsg = "Database error creating a connection object when from " & strMod_Name
            Call gmLog_SQL_Error (strMsg, sql, objConn, strMod_Name)
            Exit function
      End if
            objConn.ConnectionTimeout = 30
      objConn.CommandTimeout = 90
            objConn.Errors.Clear
      Err.clear
------------------------------------------------------------
          8.)      objConn.Open sConn_String
-------------------------------------------------------------
      If Err.Number <> 0 then
      strMsg = "Database error opening a connection when called from " & strMod_Name
            sql = "SQL Statement: Opening connection."
            Call gmLog_SQL_Error(strMsg, sql, objConn, strMod_Name)
            exit function
      End if

End Function
0
 
LVL 31

Expert Comment

by:alorentz
ID: 10876922
Then what does this function do?  Not sure why you are using this:

gmGet_App_State(strApp_Var, "String")

''''''''''''''''''''''''''''''''''''''''''

Why not just use the application variable you set up originally, that is what its for:

sConn_String = Application("sta_Connect_String")

OR

sConn_String = "Provider=SQLOLEDB; Data Source=JDP01DB0609; Initial Catalog=AFIClaims; User ID=PK3_Operator; Password=pk2allaccess"

0
 

Author Comment

by:pradeepy
ID: 10879770
Hi ,
i have the following code, when i put response.write(Application(strpassed_val) at the starting it is returning the correct application variable value

Function gmGet_App_State(strPassed_Val, strVal_Type)
      response.write(Application(strpassed_val)
      if Trim(Application(strPassed_Val) & "") = "" then
            Select Case strVal_Type
                  Case "String"
                        gmGet_App_State = ""
                  Case Else
                        gmGet_App_State = 0
            End Select
      else
      gmGet_App_State = Application(strPassed_Val).Value
      end if       
End Function
0
 
LVL 31

Accepted Solution

by:
alorentz earned 500 total points
ID: 10879968
gmGet_App_State = Application(strPassed_Val).Value

Should be: (no value)

gmGet_App_State = Application(strPassed_Val)


AND function should be:


Function gmGet_App_State(strPassed_Val, strVal_Type)
     response.write(Application(strpassed_val)
     if Application(strPassed_Val)<>"" then
          gmGet_App_State = Application(strPassed_Val).Value
     else
          Select Case strVal_Type
               Case "String"
                    gmGet_App_State = ""
               Case Else
                    gmGet_App_State = 0
          End Select
     end if      
End Function


You should also try writing gmGet_App_State right before you try to open it to see what it has in it:

 Dim sConn_String, sql, strMsg, strApp_Var    
     strApp_Var = "sta_Connect_String"
     response.write "Connection: " & gmGet_App_State(strApp_Var, "String")
     response.end
     sConn_String =gmGet_App_State(strApp_Var, "String") 'gmGet_App_State(strApp_Var, "String")


However your use of application variables and the call to connectin in this fashion is highly unnecessary, and only makes coding more confusing in the long run.  Should put your connection info in an include file and put it at the top of every page.  That way you can change it when necessary, and it's not an application variable which slows things down.

0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now