Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Sam Sam is offline
external usenet poster
 
Posts: 699
Default error displayed on rs.open when using late binding

Hi All,

I am getting an error on this line, when I used late binding.

rs.Open "Sheet1", cn, adOpenKeyset, adLockOptimistic, adCmdTable

Am I missing something or doing something wrong? I am using ADO to connect.

Thanks in advance
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default error displayed on rs.open when using late binding

What is the error? How did you declare rs? Did cn successfully connect?

Post the entire routine so we can see what is going on.
--
HTH...

Jim Thomlinson


"sam" wrote:

Hi All,

I am getting an error on this line, when I used late binding.

rs.Open "Sheet1", cn, adOpenKeyset, adLockOptimistic, adCmdTable

Am I missing something or doing something wrong? I am using ADO to connect.

Thanks in advance

  #3   Report Post  
Posted to microsoft.public.excel.programming
Sam Sam is offline
external usenet poster
 
Posts: 699
Default error displayed on rs.open when using late binding

Sorry for not posting it before. Here is my code.

Dim cn As Object
Dim rs As Object

Set cn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")

cn.Open "Provider=Microsoft.ACE.OLEDB.12.0; " & _
"Data Source=H:\Demo\Demo.accdb; Jet OLEDB:Database Password=pass; "

rs.Open "Sheet1", cn, adOpenKeyset, adLockOptimistic, adCmdTable


Thanks in advance


"Jim Thomlinson" wrote:

What is the error? How did you declare rs? Did cn successfully connect?

Post the entire routine so we can see what is going on.
--
HTH...

Jim Thomlinson


"sam" wrote:

Hi All,

I am getting an error on this line, when I used late binding.

rs.Open "Sheet1", cn, adOpenKeyset, adLockOptimistic, adCmdTable

Am I missing something or doing something wrong? I am using ADO to connect.

Thanks in advance

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default error displayed on rs.open when using late binding

Hi Sam

You must use the number for

adOpenKeyset

adLockOptimistic
....................


Set a reference to activex data objects and enter this in the Immediate window in the VBA editor

? adOpenKeyset

After you press enter you see the number



Maybe this page will help
http://www.rondebruin.nl/ado.htm




--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"sam" wrote in message ...
Hi All,

I am getting an error on this line, when I used late binding.

rs.Open "Sheet1", cn, adOpenKeyset, adLockOptimistic, adCmdTable

Am I missing something or doing something wrong? I am using ADO to connect.

Thanks in advance

  #5   Report Post  
Posted to microsoft.public.excel.programming
Sam Sam is offline
external usenet poster
 
Posts: 699
Default error displayed on rs.open when using late binding

Thanks for the help ron,

Do you know where I could find this number associations? and how to use them
here?

Thanks in advance

"Ron de Bruin" wrote:

Hi Sam

You must use the number for

adOpenKeyset

adLockOptimistic
....................


Set a reference to activex data objects and enter this in the Immediate window in the VBA editor

? adOpenKeyset

After you press enter you see the number



Maybe this page will help
http://www.rondebruin.nl/ado.htm




--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"sam" wrote in message ...
Hi All,

I am getting an error on this line, when I used late binding.

rs.Open "Sheet1", cn, adOpenKeyset, adLockOptimistic, adCmdTable

Am I missing something or doing something wrong? I am using ADO to connect.

Thanks in advance




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default error displayed on rs.open when using late binding

Assuming your table name to be sheet1 your code looks fine. One thing to note
is that with late binding the constant values that you normally get from the
library references no longer exist. You need to either hard code the numbers
or declare the constants yourself...

Public Const adCmdTable As Long = 2
Public Const adOpenKeyset As Long = 1
Public Const adLockOptimistic As Long = 3


Sub test()
Dim cn As Object
Dim rs As Object

Set cn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")

cn.Open "Provider=Microsoft.ACE.OLEDB.12.0; " & _
"Data Source=H:\Demo\Demo.accdb; Jet OLEDB:Database Password=pass; "

rs.Open "Sheet1", cn, adOpenKeyset, adLockOptimistic, adCmdTable

End Sub

When I use late binding I always get my code runnig with early binding and
then modify it to work with late binding. Compiling shows me the things I
need to fix.
--
HTH...

Jim Thomlinson


"sam" wrote:

Sorry for not posting it before. Here is my code.

Dim cn As Object
Dim rs As Object

Set cn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")

cn.Open "Provider=Microsoft.ACE.OLEDB.12.0; " & _
"Data Source=H:\Demo\Demo.accdb; Jet OLEDB:Database Password=pass; "

rs.Open "Sheet1", cn, adOpenKeyset, adLockOptimistic, adCmdTable


Thanks in advance


"Jim Thomlinson" wrote:

What is the error? How did you declare rs? Did cn successfully connect?

Post the entire routine so we can see what is going on.
--
HTH...

Jim Thomlinson


"sam" wrote:

Hi All,

I am getting an error on this line, when I used late binding.

rs.Open "Sheet1", cn, adOpenKeyset, adLockOptimistic, adCmdTable

Am I missing something or doing something wrong? I am using ADO to connect.

Thanks in advance

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default error displayed on rs.open when using late binding

You can do it like this

Set a reference to activex data objects and enter this in the Immediate window in the VBA editor

? adOpenKeyset

After you press enter you see the number



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"sam" wrote in message ...
Thanks for the help ron,

Do you know where I could find this number associations? and how to use them
here?

Thanks in advance

"Ron de Bruin" wrote:

Hi Sam

You must use the number for

adOpenKeyset

adLockOptimistic
....................


Set a reference to activex data objects and enter this in the Immediate window in the VBA editor

? adOpenKeyset

After you press enter you see the number



Maybe this page will help
http://www.rondebruin.nl/ado.htm




--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"sam" wrote in message ...
Hi All,

I am getting an error on this line, when I used late binding.

rs.Open "Sheet1", cn, adOpenKeyset, adLockOptimistic, adCmdTable

Am I missing something or doing something wrong? I am using ADO to connect.

Thanks in advance


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default error displayed on rs.open when using late binding

Oops

If you not see the Immediate window
Press Ctrl g




--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"sam" wrote in message ...
Thanks for the help ron,

Do you know where I could find this number associations? and how to use them
here?

Thanks in advance

"Ron de Bruin" wrote:

Hi Sam

You must use the number for

adOpenKeyset

adLockOptimistic
....................


Set a reference to activex data objects and enter this in the Immediate window in the VBA editor

? adOpenKeyset

After you press enter you see the number



Maybe this page will help
http://www.rondebruin.nl/ado.htm




--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"sam" wrote in message ...
Hi All,

I am getting an error on this line, when I used late binding.

rs.Open "Sheet1", cn, adOpenKeyset, adLockOptimistic, adCmdTable

Am I missing something or doing something wrong? I am using ADO to connect.

Thanks in advance


  #9   Report Post  
Posted to microsoft.public.excel.programming
Sam Sam is offline
external usenet poster
 
Posts: 699
Default error displayed on rs.open when using late binding

Thanks for your help jim, I was getting an error with :

Public Const adCmdTable As Long = 2
Public Const adOpenKeyset As Long = 1
Public Const adLockOptimistic As Long = 3

But putting it this way worked:

rs.Open "Sheet1", cn, 1, 3, 2

The above example is live and working fine as of now, I havnt declared
"adOpenKeyset, adLockOptimistic, adCmdTable" But it is working as of now,
Also I tried it like this and it didnt give me any compile errors:

Dim cn As Object
Dim rs As Object

Set cn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")

cn.Open "Provider=Microsoft.ACE.OLEDB.12.0; " & _
"Data Source=H:\Demo.accdb; Jet OLEDB:Database Password=pass; "

Dim adOpenKeyset
Dim adLockOptimistic
Dim adCmdTable

adOpenKeyset = 1
adLockOptimistic = 3
adCmdTable = 2

rs.Open "Sheet1", cn, adOpenKeyset, adLockOptimistic, adCmdTable

"Jim Thomlinson" wrote:

Assuming your table name to be sheet1 your code looks fine. One thing to note
is that with late binding the constant values that you normally get from the
library references no longer exist. You need to either hard code the numbers
or declare the constants yourself...

Public Const adCmdTable As Long = 2
Public Const adOpenKeyset As Long = 1
Public Const adLockOptimistic As Long = 3


Sub test()
Dim cn As Object
Dim rs As Object

Set cn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")

cn.Open "Provider=Microsoft.ACE.OLEDB.12.0; " & _
"Data Source=H:\Demo\Demo.accdb; Jet OLEDB:Database Password=pass; "

rs.Open "Sheet1", cn, adOpenKeyset, adLockOptimistic, adCmdTable

End Sub

When I use late binding I always get my code runnig with early binding and
then modify it to work with late binding. Compiling shows me the things I
need to fix.
--
HTH...

Jim Thomlinson


"sam" wrote:

Sorry for not posting it before. Here is my code.

Dim cn As Object
Dim rs As Object

Set cn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")

cn.Open "Provider=Microsoft.ACE.OLEDB.12.0; " & _
"Data Source=H:\Demo\Demo.accdb; Jet OLEDB:Database Password=pass; "

rs.Open "Sheet1", cn, adOpenKeyset, adLockOptimistic, adCmdTable


Thanks in advance


"Jim Thomlinson" wrote:

What is the error? How did you declare rs? Did cn successfully connect?

Post the entire routine so we can see what is going on.
--
HTH...

Jim Thomlinson


"sam" wrote:

Hi All,

I am getting an error on this line, when I used late binding.

rs.Open "Sheet1", cn, adOpenKeyset, adLockOptimistic, adCmdTable

Am I missing something or doing something wrong? I am using ADO to connect.

Thanks in advance

  #10   Report Post  
Posted to microsoft.public.excel.programming
Sam Sam is offline
external usenet poster
 
Posts: 699
Default error displayed on rs.open when using late binding

Thanks ron, this worked out for me. you can check my reply for Jim to know
what worked for me.

"Ron de Bruin" wrote:

Oops

If you not see the Immediate window
Press Ctrl g




--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"sam" wrote in message ...
Thanks for the help ron,

Do you know where I could find this number associations? and how to use them
here?

Thanks in advance

"Ron de Bruin" wrote:

Hi Sam

You must use the number for

adOpenKeyset

adLockOptimistic
....................


Set a reference to activex data objects and enter this in the Immediate window in the VBA editor

? adOpenKeyset

After you press enter you see the number



Maybe this page will help
http://www.rondebruin.nl/ado.htm




--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"sam" wrote in message ...
Hi All,

I am getting an error on this line, when I used late binding.

rs.Open "Sheet1", cn, adOpenKeyset, adLockOptimistic, adCmdTable

Am I missing something or doing something wrong? I am using ADO to connect.

Thanks in advance


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
From Early binding to Late binding Henk Excel Programming 1 February 12th 09 11:37 AM
Late binding to Excel from Access causing Object error EagleOne@microsoftdiscussiongroups[_2_] Excel Discussion (Misc queries) 4 June 14th 08 12:45 AM
Run-time error using late binding DaBookshah Excel Programming 6 June 20th 06 08:27 AM
Late Binding examples of binding excel application HeatherO Excel Programming 13 March 17th 05 08:19 AM
EARLY binding or LATE binding ? jason Excel Programming 6 February 26th 04 04:57 PM


All times are GMT +1. The time now is 03:02 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"