Unix Technical Forum

Populating an Access combo box with large amount of data causes table lock in SQL Server

This is a discussion on Populating an Access combo box with large amount of data causes table lock in SQL Server within the SQL Server forums, part of the Microsoft SQL Server category; --> I have a combo box where users select the customer name and can either go to the customer's info ...


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

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-29-2008, 04:26 AM
Roy Padgett
 
Posts: n/a
Default Populating an Access combo box with large amount of data causes table lock in SQL Server

I have a combo box where users select the customer name and can either
go to the customer's info or open a list of the customer's orders.

The RowSource for the combo box was a simple pass-through query:
SELECT DISTINCT [Customer ID], [Company Name], [contact name],City,
Region FROM Customers ORDER BY Customers.[Company Name];

This was working fine until a couple of weeks ago. Now whenever
someone has the form open, this statement locks the entire Customers
table.

I thought a pass-through query was read-only, so how does this do a
table lock?

I changed the code to an unbound rowsource that asks for input of the
first few characters first, then uses this SQL statement as the
rowsource:
SELECT [Customer ID], [Company Name], [contact name],City, Region From
dbo_Customers WHERE [Company Name] like '" & txtInput & "*' ORDER BY
[Company Name];

This helps, but if someone types only one letter, it could still be
pulling a few thousand records and cause a table lock.

What is the best way to populate a large combo box? I have too much
data for the ADODB recordset to use the .AddItem method

I was trying to figure out how to use an ADODB connection, so that I
can make it read-only to eliminate the locking, but I'm striking out
on my own.

Any ideas would be appreciated.

Roy



(Using Access 2003 MDB with SQL Server 2000 back end)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-29-2008, 04:27 AM
Simon Hayes
 
Posts: n/a
Default Re: Populating an Access combo box with large amount of data causes table lock in SQL Server


"Roy Padgett" <roy@padgett.net> wrote in message
news:b0ae64bc.0410040946.32bd1ada@posting.google.c om...
>I have a combo box where users select the customer name and can either
> go to the customer's info or open a list of the customer's orders.
>
> The RowSource for the combo box was a simple pass-through query:
> SELECT DISTINCT [Customer ID], [Company Name], [contact name],City,
> Region FROM Customers ORDER BY Customers.[Company Name];
>
> This was working fine until a couple of weeks ago. Now whenever
> someone has the form open, this statement locks the entire Customers
> table.
>
> I thought a pass-through query was read-only, so how does this do a
> table lock?
>
> I changed the code to an unbound rowsource that asks for input of the
> first few characters first, then uses this SQL statement as the
> rowsource:
> SELECT [Customer ID], [Company Name], [contact name],City, Region From
> dbo_Customers WHERE [Company Name] like '" & txtInput & "*' ORDER BY
> [Company Name];
>
> This helps, but if someone types only one letter, it could still be
> pulling a few thousand records and cause a table lock.
>
> What is the best way to populate a large combo box? I have too much
> data for the ADODB recordset to use the .AddItem method
>
> I was trying to figure out how to use an ADODB connection, so that I
> can make it read-only to eliminate the locking, but I'm striking out
> on my own.
>
> Any ideas would be appreciated.
>
> Roy
>
>
>
> (Using Access 2003 MDB with SQL Server 2000 back end)


Any time you issue a query with no WHERE clause (your first query), you're
asking SQL Server to scan the whole table, so the only thing it can do is
take some sort of exclusive lock to prevent data changing as it's reading
the table. Adding a WHERE clause allows SQL Server to use indexes to reduce
the number of rows it has to read, but as you say, if the number of rows is
large, or if the indexes aren't useful, then it may scan the table anyway.

It would be useful to know what the table structure looks like and what the
current indexes are, ie. CREATE TABLE and CREATE INDEX scripts for the
table. If the Customers table is mainly used for queries like the ones
above, then you could consider a clustered index on [Company Name], so that
the data is already in the order you need.

You also say that the table is locked while "the form is open" - this
suggests that your front end may be starting a transaction, then not
committing it until the form is closed. From the back end, you can use DBCC
OPENTRAN to is there's an open transaction, and DBCC INPUTBUFFER,
fn_get_sql() or Profiler to see what the SPID is doing. If there is an open
transaction, you'll need to look into what exactly Access is doing - you
might want to post in an Access group also, as this may be a common issue in
the Access world.

Simon


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-29-2008, 04:28 AM
Oscar Santiesteban Jr.
 
Posts: n/a
Default Re: Populating an Access combo box with large amount of data causes table lock in SQL Server

Try looking at the "WITH NOLOCK" syntax of SQL Server, I don't remember it
off the top of my head.
This will make sure that no locks are held.

Oscar...

"Roy Padgett" <roy@padgett.net> wrote in message
news:b0ae64bc.0410040946.32bd1ada@posting.google.c om...
> I have a combo box where users select the customer name and can either
> go to the customer's info or open a list of the customer's orders.
>
> The RowSource for the combo box was a simple pass-through query:
> SELECT DISTINCT [Customer ID], [Company Name], [contact name],City,
> Region FROM Customers ORDER BY Customers.[Company Name];
>
> This was working fine until a couple of weeks ago. Now whenever
> someone has the form open, this statement locks the entire Customers
> table.
>
> I thought a pass-through query was read-only, so how does this do a
> table lock?
>
> I changed the code to an unbound rowsource that asks for input of the
> first few characters first, then uses this SQL statement as the
> rowsource:
> SELECT [Customer ID], [Company Name], [contact name],City, Region From
> dbo_Customers WHERE [Company Name] like '" & txtInput & "*' ORDER BY
> [Company Name];
>
> This helps, but if someone types only one letter, it could still be
> pulling a few thousand records and cause a table lock.
>
> What is the best way to populate a large combo box? I have too much
> data for the ADODB recordset to use the .AddItem method
>
> I was trying to figure out how to use an ADODB connection, so that I
> can make it read-only to eliminate the locking, but I'm striking out
> on my own.
>
> Any ideas would be appreciated.
>
> Roy
>
>
>
> (Using Access 2003 MDB with SQL Server 2000 back end)



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 01:07 PM.


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