If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Troubles with ADO

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-10-04, 07:03
RuiPTSantos RuiPTSantos is offline
Registered User
 
Join Date: Feb 2004
Posts: 5
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
------------------------------------------
Reply With Quote
  #2 (permalink)  
Old 02-10-04, 13:02
Seppuku Seppuku is offline
Useless...
 
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.
Reply With Quote
  #3 (permalink)  
Old 02-11-04, 19:04
gyuan gyuan is offline
Registered User
 
Join Date: Dec 2003
Posts: 454
Your code posted is VB, not ASP.

Last edited by gyuan; 02-12-04 at 13:39.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On