Unix Technical Forum

Driver caching db??

This is a discussion on Driver caching db?? within the MS SQL ODBC forums, part of the Microsoft SQL Server category; --> Hello, I'm not sure if this message belongs in microsoft.public.sqlserver.msde or is more appropriate here. Please accept my apologies ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > MS SQL ODBC

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-27-2008, 08:15 PM
JohnD
 
Posts: n/a
Default Driver caching db??

Hello,

I'm not sure if this message belongs in microsoft.public.sqlserver.msde
or is more appropriate here. Please accept my apologies if I have the
wrong list.

I've written ODBC source in C++ that accesses an MSDE instance on a
local machine. I perform the usual steps:

1. Allocate an SQLHENV
2. Allocate the SQLHDBC
3. Connect
4. Execute a statement to "use " my database
5. Issue a simple query
6. Process results
7. Disconnect SQLHDBC
8. Free SQLHDBC
9. Free SQLHENV
10. Exit application

Then I try to attach to the database in SQL Server Enterprise Manager
which returns the following error:

"Error 5123: CREATE FILE encountered operating system error 32 (The
process cannot access the file because it is being used by another
process.) while attempting to open or create the physical file:
'C:\mydb.mdf'.

Do I need to do something different to force the driver to unload the
database when the application ends?

Thanks,
John
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-27-2008, 08:15 PM
Brannon Jones
 
Posts: n/a
Default Re: Driver caching db??

The driver does not touch the database file directly. The SQL Server
process will open (and lock) the database file.

Is the database hosted in a different SQL instance, than the one you are
connecting to in Enterprise Manager?

Brannon

"JohnD" <john_nospam@tech-testing.com> wrote in message
news:hqpUc.8189$YU1.7939@newssvr22.news.prodigy.co m...
> Hello,
>
> I'm not sure if this message belongs in microsoft.public.sqlserver.msde
> or is more appropriate here. Please accept my apologies if I have the
> wrong list.
>
> I've written ODBC source in C++ that accesses an MSDE instance on a
> local machine. I perform the usual steps:
>
> 1. Allocate an SQLHENV
> 2. Allocate the SQLHDBC
> 3. Connect
> 4. Execute a statement to "use " my database
> 5. Issue a simple query
> 6. Process results
> 7. Disconnect SQLHDBC
> 8. Free SQLHDBC
> 9. Free SQLHENV
> 10. Exit application
>
> Then I try to attach to the database in SQL Server Enterprise Manager
> which returns the following error:
>
> "Error 5123: CREATE FILE encountered operating system error 32 (The
> process cannot access the file because it is being used by another
> process.) while attempting to open or create the physical file:
> 'C:\mydb.mdf'.
>
> Do I need to do something different to force the driver to unload the
> database when the application ends?
>
> Thanks,
> John


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-27-2008, 08:15 PM
JohnD
 
Posts: n/a
Default Re: Driver caching db??

Brannon Jones wrote:
> Is the database hosted in a different SQL instance, than the one you are
> connecting to in Enterprise Manager?


Yes it is. I'm assuming (really I didn't know this...) that this makes
a different?

The application is using a default SQLSERVER instance and the attaching
is occurring in another DBINSTANCE.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-27-2008, 08:15 PM
Brannon Jones
 
Posts: n/a
Default Re: Driver caching db??

I don't think you can attach a single database to two different SQL
instances. The first instance that loads the database locks it for
exclusive access. So the second instance that tries to load the database
wont be able to.

Brannon

"JohnD" <john_nospam@tech-testing.com> wrote in message
news:d6vUc.1687$lY3.1035@newssvr23.news.prodigy.co m...
> Brannon Jones wrote:
> > Is the database hosted in a different SQL instance, than the one you are
> > connecting to in Enterprise Manager?

>
> Yes it is. I'm assuming (really I didn't know this...) that this makes
> a different?
>
> The application is using a default SQLSERVER instance and the attaching
> is occurring in another DBINSTANCE.


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-27-2008, 08:15 PM
John Dubchak
 
Posts: n/a
Default Re: Driver caching db??

Brannon Jones wrote:

> I don't think you can attach a single database to two different SQL
> instances. The first instance that loads the database locks it for
> exclusive access. So the second instance that tries to load the database
> wont be able to.


Which explains why I have to stop the instance in order for the other
instance to attach to it.

Thank you very much Brannon for the clarification.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
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

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


All times are GMT. The time now is 07:13 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com