Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2004
    Posts
    5

    Unanswered: Troubles with ADO

    Hello. I'm a novice and started to build a ADO database (MsAccess). I've developed the code shown below and it returns me an error, 'Object variable or with variable not set'. Then it returns me to the line that I marked with XXXXXXXXXXXXXXXXXXXXXXXX. What's the problem?

    --------------------------------
    Option Compare Database
    Dim con As Connection
    Dim rst As Recordset

    -----------------------
    Private Sub Form_Load()

    Limpar
    Inicializar_Variaveis

    End Sub
    -----------------------------
    Sub Inicializar_Variaveis()

    Set con = New Connection
    Set rst = New Recordset
    Set con = CurrentProject.Connection

    End Sub
    ------------------------------
    Private Sub cmdConfAdicionarCliente_Click()

    cliente = txtNomeCliente
    varSQL = "INSERT INTO tblClientes (NomeCliente) VALUES (" & cliente & ");"
    rst.Open varSQL, con -XXXXXXXXXXXXXXXXXXXXXXXXXXXXX-
    Inicializar_Variaveis
    Limpar

    End Sub
    -----------------------------------
    Sub Limpar()

    txtNomeCliente.Visible = False
    cmdConfAdicionarCliente.Visible = False

    End Sub

    ----------------------------------------
    Private Sub cmdAdicionarCliente_Click()

    txtNomeCliente.Visible = True
    cmdConfAdicionarCliente.Visible = True
    cmdAlterarCliente.Enabled = False
    cmdPesquisarCliente.Enabled = False


    End Sub
    ------------------------------------------

  2. #2
    Join Date
    Jul 2003
    Location
    SoCal
    Posts
    721
    Is this for VB, VBScript or for ASP?

    In ASP, there is no "AS" keyword, so when you Dim something, you Dim just the variable name, no "AS Connection", etc

    Second, I don't think "Option Compare Database" are ASP keywords, nor is "Private", or "New". If you're creating a new ADO object, use "Server.CreateObject()":

    Set con = Server.CreateObject("ADODB.Connection")

    You have a line:
    Set con = New Connection
    Then another line:
    Set con = CurrentProject.Connection

    I'm not sure why you're doing this, but "CurrentProject" is not an ASP object... drop that whole line

    Then you have a bunch of objects with ".Visible" and ".Enabled" properties... these are also invalid in ASP
    That which does not kill me postpones the inevitable.

  3. #3
    Join Date
    Dec 2003
    Posts
    454
    Your code posted is VB, not ASP.
    Last edited by gyuan; 02-12-04 at 14:39.

Posting Permissions

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