By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,660 Members | 1,735 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,660 IT Pros & Developers. It's quick & easy.

asp.net and access database locking?

P: n/a
Hi

Having problems using an access database where i seem to create a locked
file on making a connection.

I think ive covered all the basics like properly closing the connection
etc....
Are there any probs with setting connections in web.config that might create
this problem?

I've included a simplified version of the code in question below.

In my local test enviroment i can restart IIS to remove the lock, i cant do
this live as i use shared hosting evironment and have no control over the
box.
Anyone ever come across anything like this?

Thanks in advance
amessimon

'##########################################

'connection string in web.config
Dim strConnection as string =
ConfigurationSettings.AppSettings("ConnectionStrin g")
Dim strSQL as string = SQL statement...............
Dim objConnection as New OledbConnection(strConnection)
Dim objCommand as New OledbCommand(strSQL,objConnection)
Dim objDataReader as OledbDataReader
objConnection.Open()
objDataReader = objCommand.ExecuteReader()

Do While objDataReader.Read() = true
'etc.................
Loop

objDataReader.close()
objConnection.close()

'##########################################

Nov 18 '05 #1
Share this Question
Share on Google+
14 Replies


P: n/a
I have run across this.. In my case it was because the Access database was
being used by another network user directly from Access.

-Brian

"amessimon" <am*******************@hotmail.com> wrote in message
news:uM*************@TK2MSFTNGP09.phx.gbl...
Hi

Having problems using an access database where i seem to create a locked
file on making a connection.

I think ive covered all the basics like properly closing the connection
etc....
Are there any probs with setting connections in web.config that might create this problem?

I've included a simplified version of the code in question below.

In my local test enviroment i can restart IIS to remove the lock, i cant do this live as i use shared hosting evironment and have no control over the
box.
Anyone ever come across anything like this?

Thanks in advance
amessimon

'##########################################

'connection string in web.config
Dim strConnection as string =
ConfigurationSettings.AppSettings("ConnectionStrin g")
Dim strSQL as string = SQL statement...............
Dim objConnection as New OledbConnection(strConnection)
Dim objCommand as New OledbCommand(strSQL,objConnection)
Dim objDataReader as OledbDataReader
objConnection.Open()
objDataReader = objCommand.ExecuteReader()

Do While objDataReader.Read() = true
'etc.................
Loop

objDataReader.close()
objConnection.close()

'##########################################


Nov 18 '05 #2

P: n/a
I think you need to add "Mode=16" to your connection string.

"amessimon" <am*******************@hotmail.com> wrote in message
news:uM*************@TK2MSFTNGP09.phx.gbl...
Hi

Having problems using an access database where i seem to create a locked
file on making a connection.

I think ive covered all the basics like properly closing the connection
etc....
Are there any probs with setting connections in web.config that might
create
this problem?

I've included a simplified version of the code in question below.

In my local test enviroment i can restart IIS to remove the lock, i cant
do
this live as i use shared hosting evironment and have no control over the
box.
Anyone ever come across anything like this?

Thanks in advance
amessimon

'##########################################

'connection string in web.config
Dim strConnection as string =
ConfigurationSettings.AppSettings("ConnectionStrin g")
Dim strSQL as string = SQL statement...............
Dim objConnection as New OledbConnection(strConnection)
Dim objCommand as New OledbCommand(strSQL,objConnection)
Dim objDataReader as OledbDataReader
objConnection.Open()
objDataReader = objCommand.ExecuteReader()

Do While objDataReader.Read() = true
'etc.................
Loop

objDataReader.close()
objConnection.close()

'##########################################


Nov 18 '05 #3

P: n/a
Probably a stupid question....but this is difficult to test as i have to
either copy and rename the database or restart IIS everytime i test
this...so i'll ask it.

Is this another node or an attribute. Where do i add this?
Also what does this mode setting do exactly, i'm having trouble finding
references online.

Thanks in advance

"Steven" <ms******@berkovitz.org> wrote in message
news:uC**************@TK2MSFTNGP12.phx.gbl...
I think you need to add "Mode=16" to your connection string.

"amessimon" <am*******************@hotmail.com> wrote in message
news:uM*************@TK2MSFTNGP09.phx.gbl...
Hi

Having problems using an access database where i seem to create a locked
file on making a connection.

I think ive covered all the basics like properly closing the connection
etc....
Are there any probs with setting connections in web.config that might
create
this problem?

I've included a simplified version of the code in question below.

In my local test enviroment i can restart IIS to remove the lock, i cant
do
this live as i use shared hosting evironment and have no control over the box.
Anyone ever come across anything like this?

Thanks in advance
amessimon

'##########################################

'connection string in web.config
Dim strConnection as string =
ConfigurationSettings.AppSettings("ConnectionStrin g")
Dim strSQL as string = SQL statement...............
Dim objConnection as New OledbConnection(strConnection)
Dim objCommand as New OledbCommand(strSQL,objConnection)
Dim objDataReader as OledbDataReader
objConnection.Open()
objDataReader = objCommand.ExecuteReader()

Do While objDataReader.Read() = true
'etc.................
Loop

objDataReader.close()
objConnection.close()

'##########################################



Nov 18 '05 #4

P: n/a
If you have made your connection via the Server Explorer window in VS .NET,
then the .ldb file will remain regardless of the state of the connection
object because VS .NET maintains a pathway to the DB.

Even if you didn't use the Server Explorer window to create the connection,
the .ldb file remains because ADO .NET uses connection pooling by default.
So, even if you close the connection explicitly, the connection will still
exist in the pool. To disable connection pooling add "OLE DB Services=-4"
to your connection string.
"amessimon" <am*******************@hotmail.com> wrote in message
news:uM*************@TK2MSFTNGP09.phx.gbl...
Hi

Having problems using an access database where i seem to create a locked
file on making a connection.

I think ive covered all the basics like properly closing the connection
etc....
Are there any probs with setting connections in web.config that might create this problem?

I've included a simplified version of the code in question below.

In my local test enviroment i can restart IIS to remove the lock, i cant do this live as i use shared hosting evironment and have no control over the
box.
Anyone ever come across anything like this?

Thanks in advance
amessimon

'##########################################

'connection string in web.config
Dim strConnection as string =
ConfigurationSettings.AppSettings("ConnectionStrin g")
Dim strSQL as string = SQL statement...............
Dim objConnection as New OledbConnection(strConnection)
Dim objCommand as New OledbCommand(strSQL,objConnection)
Dim objDataReader as OledbDataReader
objConnection.Open()
objDataReader = objCommand.ExecuteReader()

Do While objDataReader.Read() = true
'etc.................
Loop

objDataReader.close()
objConnection.close()

'##########################################


Nov 18 '05 #5

P: n/a
Have you tried setting your clock to the correct month?

"amessimon" <am*******************@hotmail.com> wrote in message
news:uM*************@TK2MSFTNGP09.phx.gbl...
Hi

Having problems using an access database where i seem to create a locked
file on making a connection.

I think ive covered all the basics like properly closing the connection
etc....
Are there any probs with setting connections in web.config that might create this problem?

I've included a simplified version of the code in question below.

In my local test enviroment i can restart IIS to remove the lock, i cant do this live as i use shared hosting evironment and have no control over the
box.
Anyone ever come across anything like this?

Thanks in advance
amessimon

'##########################################

'connection string in web.config
Dim strConnection as string =
ConfigurationSettings.AppSettings("ConnectionStrin g")
Dim strSQL as string = SQL statement...............
Dim objConnection as New OledbConnection(strConnection)
Dim objCommand as New OledbCommand(strSQL,objConnection)
Dim objDataReader as OledbDataReader
objConnection.Open()
objDataReader = objCommand.ExecuteReader()

Do While objDataReader.Read() = true
'etc.................
Loop

objDataReader.close()
objConnection.close()

'##########################################


Nov 18 '05 #6

P: n/a
Jos
amessimon wrote:
Hi

Having problems using an access database where i seem to create a
locked file on making a connection.

I think ive covered all the basics like properly closing the
connection etc....
Are there any probs with setting connections in web.config that might
create this problem?

I've included a simplified version of the code in question below.

In my local test enviroment i can restart IIS to remove the lock, i
cant do this live as i use shared hosting evironment and have no
control over the box.
Anyone ever come across anything like this?

Thanks in advance
amessimon

'##########################################

'connection string in web.config
Dim strConnection as string =
ConfigurationSettings.AppSettings("ConnectionStrin g")
Dim strSQL as string = SQL statement...............
Dim objConnection as New OledbConnection(strConnection)
Dim objCommand as New OledbCommand(strSQL,objConnection)
Dim objDataReader as OledbDataReader
objConnection.Open()
objDataReader = objCommand.ExecuteReader()

Do While objDataReader.Read() = true
'etc.................
Loop

objDataReader.close()
objConnection.close()

'##########################################


For Access connections, I always use an exception block.
If anything goes wrong, you can make sure that the connection
doesn't stay open. If it does stay open, you'll have to kill the
ASPNET process or even restart the server to get access again.

Dim objConnection As New OleDbConnection(strConnection)
Try
' do your stuff here
Finally
objConnection.Close()
End Try

--

Jos
Nov 18 '05 #7

P: n/a
IN the connstring add mode=16; (in web.config). I have not seen this, but I
will run with it (ignorance is bliss ;->)

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************
"amessimon" <am*******************@hotmail.com> wrote in message
news:eZ**************@TK2MSFTNGP10.phx.gbl...
Probably a stupid question....but this is difficult to test as i have to
either copy and rename the database or restart IIS everytime i test
this...so i'll ask it.

Is this another node or an attribute. Where do i add this?
Also what does this mode setting do exactly, i'm having trouble finding
references online.

Thanks in advance

"Steven" <ms******@berkovitz.org> wrote in message
news:uC**************@TK2MSFTNGP12.phx.gbl...
I think you need to add "Mode=16" to your connection string.

"amessimon" <am*******************@hotmail.com> wrote in message
news:uM*************@TK2MSFTNGP09.phx.gbl...
Hi

Having problems using an access database where i seem to create a locked file on making a connection.

I think ive covered all the basics like properly closing the connection etc....
Are there any probs with setting connections in web.config that might
create
this problem?

I've included a simplified version of the code in question below.

In my local test enviroment i can restart IIS to remove the lock, i cant do
this live as i use shared hosting evironment and have no control over the box.
Anyone ever come across anything like this?

Thanks in advance
amessimon

'##########################################

'connection string in web.config
Dim strConnection as string =
ConfigurationSettings.AppSettings("ConnectionStrin g")
Dim strSQL as string = SQL statement...............
Dim objConnection as New OledbConnection(strConnection)
Dim objCommand as New OledbCommand(strSQL,objConnection)
Dim objDataReader as OledbDataReader
objConnection.Open()
objDataReader = objCommand.ExecuteReader()

Do While objDataReader.Read() = true
'etc.................
Loop

objDataReader.close()
objConnection.close()

'##########################################




Nov 18 '05 #8

P: n/a
Try adding objConnection.Dispose() after the whole thing.

Access will always create a lock file, so in and out ASAP is the best
option. The dispose should mark the conn as complete and release the lock.

Also check your conn string. You can lock things up unnecessarily with the
wrong conn string.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************
"amessimon" <am*******************@hotmail.com> wrote in message
news:uM*************@TK2MSFTNGP09.phx.gbl...
Hi

Having problems using an access database where i seem to create a locked
file on making a connection.

I think ive covered all the basics like properly closing the connection
etc....
Are there any probs with setting connections in web.config that might create this problem?

I've included a simplified version of the code in question below.

In my local test enviroment i can restart IIS to remove the lock, i cant do this live as i use shared hosting evironment and have no control over the
box.
Anyone ever come across anything like this?

Thanks in advance
amessimon

'##########################################

'connection string in web.config
Dim strConnection as string =
ConfigurationSettings.AppSettings("ConnectionStrin g")
Dim strSQL as string = SQL statement...............
Dim objConnection as New OledbConnection(strConnection)
Dim objCommand as New OledbCommand(strSQL,objConnection)
Dim objDataReader as OledbDataReader
objConnection.Open()
objDataReader = objCommand.ExecuteReader()

Do While objDataReader.Read() = true
'etc.................
Loop

objDataReader.close()
objConnection.close()

'##########################################


Nov 18 '05 #9

P: n/a

"msnews.microsoft.com" <ma*****@portvista.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Have you tried setting your clock to the correct month?

It is fun! Outlook Express has not an option to "hide" this post?!
Nov 18 '05 #10

P: n/a
Why should we have to hide this post. Why not just fix the clock?

"Saber" <saber[--AT--]maghalat.com> wrote in message
news:e$*************@TK2MSFTNGP10.phx.gbl...

"msnews.microsoft.com" <ma*****@portvista.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Have you tried setting your clock to the correct month?

It is fun! Outlook Express has not an option to "hide" this post?!

Nov 18 '05 #11

P: n/a
That's right but it is not my clock, its "amessimon" clock, I'll email him.
"Scott M." <s-***@nospam.nospam> wrote in message
news:ut**************@TK2MSFTNGP11.phx.gbl...
Why should we have to hide this post. Why not just fix the clock?

"Saber" <saber[--AT--]maghalat.com> wrote in message
news:e$*************@TK2MSFTNGP10.phx.gbl...

"msnews.microsoft.com" <ma*****@portvista.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
> Have you tried setting your clock to the correct month?

It is fun! Outlook Express has not an option to "hide" this post?!


Nov 18 '05 #12

P: n/a
No one said it was your clock. The post was a reply to the OP.

"Saber" <saber[--AT--]maghalat.com> wrote in message
news:O%******************@tk2msftngp13.phx.gbl...
That's right but it is not my clock, its "amessimon" clock, I'll email him. "Scott M." <s-***@nospam.nospam> wrote in message
news:ut**************@TK2MSFTNGP11.phx.gbl...
Why should we have to hide this post. Why not just fix the clock?

"Saber" <saber[--AT--]maghalat.com> wrote in message
news:e$*************@TK2MSFTNGP10.phx.gbl...

"msnews.microsoft.com" <ma*****@portvista.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
> Have you tried setting your clock to the correct month?
It is fun! Outlook Express has not an option to "hide" this post?!



Nov 18 '05 #13

P: n/a
On Sun, 1 Aug 2004 12:18:12 -0400, "Scott M." <s-***@nospam.nospam>
wrote:
No one said it was your clock. The post was a reply to the OP.
No it wasn't.

"Saber" <saber[--AT--]maghalat.com> wrote in message
news:O%******************@tk2msftngp13.phx.gbl. ..
That's right but it is not my clock, its "amessimon" clock, I'll email

him.
"Scott M." <s-***@nospam.nospam> wrote in message
news:ut**************@TK2MSFTNGP11.phx.gbl...
> Why should we have to hide this post. Why not just fix the clock?
>
> "Saber" <saber[--AT--]maghalat.com> wrote in message
> news:e$*************@TK2MSFTNGP10.phx.gbl...
>>
>> "msnews.microsoft.com" <ma*****@portvista.com> wrote in message
>> news:%2****************@TK2MSFTNGP12.phx.gbl...
>> > Have you tried setting your clock to the correct month?
>>
>>
>> It is fun! Outlook Express has not an option to "hide" this post?!
>>
>>
>
>



Nov 18 '05 #14

P: n/a
Um, yes it was. "msnews.microsoft.com" posted a direct reply to the OP:
"Have you tried setting your clock to the correct month?" and this is what
I'm talking about.


"Duffaukid" <ji**@hal-pc.org> wrote in message
news:ck********************************@4ax.com...
On Sun, 1 Aug 2004 12:18:12 -0400, "Scott M." <s-***@nospam.nospam>
wrote:
No one said it was your clock. The post was a reply to the OP.


No it wasn't.

"Saber" <saber[--AT--]maghalat.com> wrote in message
news:O%******************@tk2msftngp13.phx.gbl.. .
That's right but it is not my clock, its "amessimon" clock, I'll email

him.
"Scott M." <s-***@nospam.nospam> wrote in message
news:ut**************@TK2MSFTNGP11.phx.gbl...
> Why should we have to hide this post. Why not just fix the clock?
>
> "Saber" <saber[--AT--]maghalat.com> wrote in message
> news:e$*************@TK2MSFTNGP10.phx.gbl...
>>
>> "msnews.microsoft.com" <ma*****@portvista.com> wrote in message
>> news:%2****************@TK2MSFTNGP12.phx.gbl...
>> > Have you tried setting your clock to the correct month?
>>
>>
>> It is fun! Outlook Express has not an option to "hide" this post?!
>>
>>
>
>

Nov 18 '05 #15

This discussion thread is closed

Replies have been disabled for this discussion.