opening database problem (access) 
Author Message
 opening database problem (access)

I currently have the following in the form_load event:

dbcn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=" & DataBaseFile
dbcn.CursorLocation = adUseClient
dbcn.Open

But I'm using it in two mdi child forms, and when I open them at the
sametime I get the following error: "Operation is not allowed when the
object is open" (but it works ok accessing it once at a time)

Is there anyway I can get this to work by accessing the same database
in two different forms?

(if module is a method, can you write exactly what code I should be
using, cause I tried the module method briefly)

Thanks for any help!



Fri, 03 Sep 2004 04:54:18 GMT  
 opening database problem (access)
HI
Before opening your connection, just check the state property of the
connection object.

if dbcn.state=adstateopen then dbcn.close

also, refer to the link:
http://www.able-consulting.com/ado_conn.htm#OLEDBProviderForMicrosoftJet

Hope it helps
Harinatha Reddy Gorla MCSD,MCDBA
        Software Engineer
Smart Software Technologies,
Hyderabad, India

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Fri, 03 Sep 2004 13:34:58 GMT  
 opening database problem (access)
Hi,

this happens probably because your dbcn variable declared
as public. In that case it is visible in all forms. If you
already opene connection using that variable, then you
will get error if you will try to do same next time. What
you can do is to chaeck State property ofconnection. If it
is opened, then do not do it again. If you nee to open
connection to another database, then you will need declare
another Connection variable or to close opened connection.

Val

Quote:
>-----Original Message-----
>I currently have the following in the form_load event:

>dbcn.ConnectionString

= "Provider=Microsoft.Jet.OLEDB.4.0;Data
Quote:
>Source=" & DataBaseFile
>dbcn.CursorLocation = adUseClient
>dbcn.Open

>But I'm using it in two mdi child forms, and when I open
them at the
>sametime I get the following error: "Operation is not
allowed when the
>object is open" (but it works ok accessing it once at a
time)

>Is there anyway I can get this to work by accessing the
same database
>in two different forms?

>(if module is a method, can you write exactly what code I
should be
>using, cause I tried the module method briefly)

>Thanks for any help!
>.



Fri, 03 Sep 2004 20:51:01 GMT  
 opening database problem (access)
try checking the dbcn object for adstateopen before opening

ie
if dbcn.state <> adstateopen then
    dbcn.open
end if

john


Quote:
> I currently have the following in the form_load event:

> dbcn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
> Source=" & DataBaseFile
> dbcn.CursorLocation = adUseClient
> dbcn.Open

> But I'm using it in two mdi child forms, and when I open them at the
> sametime I get the following error: "Operation is not allowed when the
> object is open" (but it works ok accessing it once at a time)

> Is there anyway I can get this to work by accessing the same database
> in two different forms?

> (if module is a method, can you write exactly what code I should be
> using, cause I tried the module method briefly)

> Thanks for any help!



Mon, 06 Sep 2004 10:18:31 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. opening database problem (access)

2. ACCESS 2000: Problem opening database... (info inside)

3. Problem opening Access 2K database with VB6

4. VB3 problems opening Access 1.1 database

5. Problem on open access 2.0 database by VB4

6. ACCESS 2000: Problem opening database... (info inside)

7. Problem opening Access Database

8. VB 6 Database and Access 2K Database Problem

9. VB6 accessing simple password protected Access database problems

10. password problem with accessing a access database

11. Problem accessing an Access 8 database from VB4

12. MS Access 7 Database on Network and VB5 Multi User Access Problem

 

 
Powered by phpBB® Forum Software