Results 1 to 2 of 2

Thread: Complie Error

  1. #1
    Join Date
    May 2007
    Location
    Belfast, N.I
    Posts
    3

    Arrow Unanswered: Complie Error

    Code:
    Using 
    
    Microsoft Visual Basic 6.0
    Microsoft SQL Enterprise Manager 8.0
    
    
    
    -- Form1.frm
    
    Option Explicit
    Private Sub cmdDone_Click()
    End
    End Sub
    
    Private Sub cmdLookUp_Click()
    If Trim(Text1.Text) <> "" Then
      Call GetStats
     Else
      MsgBox "Please enter a start date", vbExclamation
     End If
    If Trim(Text2.Text) <> "" Then
      Call GetStats
     Else
      MsgBox "Please enter an end date", vbExclamation
     End If
    End Sub
    Sub GetStats()
    
     Dim strSQL As String
     Dim rst As ADODB.Recordset
     
     strSQL = " CARLA_SEL '" & Text1.Text & "'" & Text2.Text & "'"
     Call ADO_Query(intCurrentConnection, strSQL, rst)
     
     lstInformation.Clear
       List1.Clear
       
    If rst.RecordCount > 0 Then
      Do While Not rst.EOF
       lstInformation.AddItem Trim(rst("SDATE")) & " " & Trim(rst("EDATE"))
             List1.AddItem Trim(rst("SDATE")) & " " & Trim(rst("EDATE"))
         rst.MoveNext
      Loop
      lstInformation.Visible = True
     Else
      MsgBox "No stats found for that date range"
     End If
    
    End Sub
    
    Private Sub Command1_Click()
    Call GetDetails
    End Sub
    
    
    Private Sub lstInformation_Click()
    
        Text1.Text = Trim(List1.List(lstInformation.ListIndex))
        Text2.Text = Trim(List1.List(lstInformation.ListIndex))
    Label3.Caption = List1.List(lstInformation.ListIndex)
    End Sub
    Private Sub lstInfo_Click()
      
        Text1.Text = (lstInformation.ListIndex + 1) & ". " & lstInformation.List(lstInformation.ListIndex)
        Text2.Text = (lstInformation.ListIndex + 1) & ". " & lstInformation.List(lstInformation.ListIndex)
    
    End Sub
    Sub GetDetails()
    
    Dim dateStartDate As Date
    Dim dateEndDate As Date
    Dim strSQL As String
    
    dateStartDate = Trim(Label3.Caption)
    dateStartDate = Trim(Text1.Text)
    dateEndDate = Trim(Text2.Text)
    
    strSQL = " CARLA_PROB1 '" & dateStartDate & "','" & dateEndDate & "','"
    Call ADO_Execute(intCurrentConnection, strSQL)
    End Sub
    Private Sub Form_Load()
    
    Top = 0
    Left = 0
    Height = 9000
    Width = 12000
    End Sub
    
    
    -- stored Procedure code; CARLA_SEL
    
    CREATE PROCEDURE CARLA_SEL
    as
    
    declare
    @startdate datetime,
    @enddate datetime
    
    begin
    select*from tblRequestMaster RM
    where RM.fldRequestDate=@startdate
    and RM.fldRequestDate=@enddate
    end
    GO
    
    
    
    --stored procedure code; CARLA_PROB1
    
    CREATE PROCEDURE CARLA_PROB1
    AS
    
    DECLARE 
    @startdate datetime,
    @enddate datetime
    
    
    -- (1) Number of calls received for each priority of call [for a specified date range]
    
    select RM.fldPriorityCode as 'Priority',
    count(RM.fldRequestID) as 'Calls'
    from tblRequestMaster RM
    where RM.fldPriorityCode between 1 and 5
    and RM.fldRequestDate between '' and ''
    and RM.fldRequestFlag like 'D'
    group by RM.fldPriorityCode 
    union
    select 
    'Total' as 'Priority',
    count(RM.fldRequestID) as 'Calls'
    from tblRequestMaster RM
    where RM.fldPriorityCode between 1 and 5
    and RM.fldRequestDate between '' and ''
    and RM.fldRequestFlag like 'D'
    order by RM.fldPriorityCode asc
    GO
    
    
    
    
    This is the code in my modules;
    
    
    
    --mod_ConnectionRoutines.bas
    
    Option Explicit
    '
    '************************************************************************************
    'Module to house the MainConnection calls
    '************************************************************************************
    '
    
    Public Function ADO_Execute(intConn As Integer, _
                                strSQL) As Boolean
    
     Err.Clear
    On Error GoTo ErrHandle:
    
    'set timeouts
     Call SetNewTimeouts
    
     ADO_Execute = True
     With clsConnectionObject
      Call .ADO_Execute(intConn, strSQL)
     End With
    
    'reset timeouts
     Call ResetTimeouts
     
     Exit Function
    
    ErrHandle:
     Call ResetTimeouts
     ADO_Execute = False
     Err.Raise Err.Number
    
    End Function
    
    Public Function ADO_Query(intConn As Integer, _
                              strSQL As String, _
                              rst As ADODB.Recordset, _
                              Optional CursorType As ADODB.CursorTypeEnum, _
                              Optional LockType As ADODB.LockTypeEnum, _
                              Optional CursorLocation As ADODB.CursorLocationEnum) As Boolean
    
     Err.Clear
    On Error GoTo ErrHandle:
    
    'set timeouts
     Call SetNewTimeouts
    
     ADO_Query = True
     With clsConnectionObject
      Call .ADO_Query(intConn, strSQL, rst, CursorType, LockType, CursorLocation)
     End With
     
    'reset timeouts
     Call ResetTimeouts
     
     Exit Function
     
    ErrHandle:
     Call ResetTimeouts
     ADO_Query = False
     Err.Raise Err.Number
    End Function
    
    
    Public Function ADO_Recordset(intConn As Integer, _
                              ByVal strSQL As String, _
                              Optional CursorType As ADODB.CursorTypeEnum, _
                              Optional LockType As ADODB.LockTypeEnum, _
                              Optional CursorLocation As ADODB.CursorLocationEnum) As ADODB.Recordset
    
     Err.Clear
    On Error GoTo ErrHandle:
    
    'set timeouts
     Call SetNewTimeouts
    
     With clsConnectionObject
       Set ADO_Recordset = .ADO_Recordset(intConn, strSQL, CursorType, LockType, CursorLocation)
     End With
     
    'reset timeouts
     Call ResetTimeouts
     
     Exit Function
     
    ErrHandle:
     Call ResetTimeouts
     Err.Raise Err.Number
     
    End Function
    
    Sub SetNewTimeouts()
    'routine to set the Component Request timeouts to 1 hour
     App.OleRequestPendingTimeout = 3600000
     App.OleServerBusyTimeout = 3600000
    End Sub
    
    Sub ResetTimeouts()
    'routine to reset the Component Request timeouts
     App.OleRequestPendingTimeout = 10000
     App.OleServerBusyTimeout = 10000
    End Sub
    
    
    --modMainConnect.bas
    
    Option Explicit
    
    'global variables for MainConnection
    
    Public gstrDSN As String
    Public gstrDBase As String
    Public gstrUser As String
    Public gstrPassword As String
    
    'array of all current DB connections
    Public strConnections(10, 4) As String
    Public intCurrentConnections(10) As Integer
    Public intTotalConnections As Integer
    
    'New global connection object for BOIS
    Public clsConnectionObject As MainConnection.clsMainConnection
    Public intCurrentConnection As Integer
    Public blnConnectionCompleted As Boolean
    
    Function ConnectToServer(strDataSource As String, _
                         strUsername As String, _
                         strPassword As String, _
                         strDBname As String) As Boolean
     
     '*********************************************************
    'Create an instance of ConnectionObject
     Set clsConnectionObject = New clsMainConnection
    '*********************************************************
    
    On Error GoTo ErrorHandle
    'now establish Connection to server database
     Call clsConnectionObject.ConnectToDB(Trim(strDataSource), Trim(strDBname), Trim(strUsername), Trim(strPassword))
    
     ConnectToServer = True
     gstrUser = strUsername
     intCurrentConnection = clsConnectionObject.intConnection
     Exit Function
      
    ErrorHandle:
     ConnectToServer = False
     Err.Clear
    
    End Function
    
    
    
    --Module1.bas
    
    Option Explicit
    
    Sub Main()
    
    If ConnectToServer("BOISSQL", "itd", "2002", "BOIS") Then
    Form1.Show
    Else
    MsgBox "Unsuccessful :::: Unable To Connect" & Err.Description
    End If
    End Sub

    When I try to run the VB code I get the following error;

    'Compile Error: User-defined type not defined'


    Can anyone tell me were I am going wrong?


    Thx

    ~ Floetic ~

  2. #2
    Join Date
    Jun 2004
    Location
    Arizona, USA
    Posts
    1,848
    Which line is generating the error?

    Dim rst As ADODB.Recordset ???

    You need to add a reference to ADO in your project.

    In the Project, References menu, select the latest version of Microsoft ActiveX Data Objects 2.x Library. (the most current is 2.8)

    Also, do NOT use the End statement. It is a holdover from Mbasic, and should never be used. This is according to microsoft. Instead, UNLOAD all objects you've created, and unload all forms.

    ref
    End - Don't Use END
    End - Don't Use End - Really...
    End - It's Evil...
    Lou
    使大吃一惊
    "Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
    "I have my standards. They may be low, but I have them!" - Bette Middler
    "It's a book about a Spanish guy named Manual. You should read it." - Dilbert


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •