473,491 Members | 2,074 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Re: Getting info from SQL DB

"Bill Schanks" <ws******@gmail.comschrieb
I have this code, that will take what is in a listview and go get
more info. Howerver on a large number of listview records this will
produce a problem (Say if I had 30,000 Listview entires).

What would be the recommended alternative? Have it load the listview
items to a table and then have my query join to that table, Put in a
check and if there are >1000 listview entires don't allow the sql
lookup?
Try to execute

lvMembers.beginupdate

before filling and

lvMembers.endupdate

afterwards. Better now?
And try this version: (an attempt)

Dim Items As String()

ReDim Items(reader.FieldCount - 1)

Do While reader.Read
Items(0) = CStr(reader(0))

For i = 1 To reader.FieldCount - 1
If reader.IsDBNull(i) Then
Items(i) = "" 'or String.Empty
Else
Items(i) = reader.GetString(i)
End If
Next i

itmListItem = New ListViewItem(Items)
lvmembers.Items.Add(itmListItem)
icount = icount + 1

Loop


Armin
Jun 27 '08 #1
11 1437
The error is coming because sSQL is too large, and I am getting the
error on SQL Excecution when there are 30000 entries in the in clause
of the sql command.

On Apr 25, 12:50 pm, "Armin Zingler" <az.nos...@freenet.dewrote:
"Bill Schanks" <wscha...@gmail.comschrieb
I have this code, that will take what is in a listview and go get
more info. Howerver on a large number of listview records this will
produce a problem (Say if I had 30,000 Listview entires).
What would be the recommended alternative? Have it load the listview
items to a table and then have my query join to that table, Put in a
check and if there are >1000 listview entires don't allow the sql
lookup?

Try to execute

lvMembers.beginupdate

before filling and

lvMembers.endupdate

afterwards. Better now?

And try this version: (an attempt)

Dim Items As String()

ReDim Items(reader.FieldCount - 1)

Do While reader.Read
Items(0) = CStr(reader(0))

For i = 1 To reader.FieldCount - 1
If reader.IsDBNull(i) Then
Items(i) = "" 'or String.Empty
Else
Items(i) = reader.GetString(i)
End If
Next i

itmListItem = New ListViewItem(Items)
lvmembers.Items.Add(itmListItem)
icount = icount + 1

Loop

Armin
Jun 27 '08 #2

"Bill Schanks" <ws******@gmail.comwrote in message
news:05**********************************@34g2000h sf.googlegroups.com...
The error is coming because sSQL is too large, and I am getting the
error on SQL Excecution when there are 30000 entries in the in clause
of the sql command.

On Apr 25, 12:50 pm, "Armin Zingler" <az.nos...@freenet.dewrote:
>"Bill Schanks" <wscha...@gmail.comschrieb
I have this code, that will take what is in a listview and go get
more info. Howerver on a large number of listview records this will
produce a problem (Say if I had 30,000 Listview entires).
What would be the recommended alternative? Have it load the listview
items to a table and then have my query join to that table, Put in a
check and if there are >1000 listview entires don't allow the sql
lookup?

Try to execute

lvMembers.beginupdate

before filling and

lvMembers.endupdate

afterwards. Better now?

And try this version: (an attempt)

Dim Items As String()

ReDim Items(reader.FieldCount - 1)

Do While reader.Read
Items(0) = CStr(reader(0))

For i = 1 To reader.FieldCount - 1
If reader.IsDBNull(i) Then
Items(i) = "" 'or String.Empty
Else
Items(i) = reader.GetString(i)
End If
Next i

itmListItem = New ListViewItem(Items)
lvmembers.Items.Add(itmListItem)
icount = icount + 1

Loop

Armin
What you want to do is if you are using ListView , make it a virtual
listview. I have samples if you need them. Can fill and display 30K items
very quickly.

LS

Jun 27 '08 #3
The error is not filling the listview, it doesn't even get to that
point. The SQL Command is the problem. Here is the error I get:

system.data.sqlclient.sqlexception: Internal query processor error:
The query processor ran out of stack space during query optimization

This is due to the IN Clause have 30000 items. My question was should
I have the program load the list view items to a table and then join
to that table to my query, or just not allow the command if the IN
Clause would have more than x number of items.

On Apr 25, 1:04 pm, "Lloyd Sheen" <a...@b.cwrote:
"Bill Schanks" <wscha...@gmail.comwrote in message

news:05**********************************@34g2000h sf.googlegroups.com...
The error is coming because sSQL is too large, and I am getting the
error on SQL Excecution when there are 30000 entries in the in clause
of the sql command.
On Apr 25, 12:50 pm, "Armin Zingler" <az.nos...@freenet.dewrote:
"Bill Schanks" <wscha...@gmail.comschrieb
I have this code, that will take what is in a listview and go get
more info. Howerver on a large number of listview records this will
produce a problem (Say if I had 30,000 Listview entires).
What would be the recommended alternative? Have it load the listview
items to a table and then have my query join to that table, Put in a
check and if there are >1000 listview entires don't allow the sql
lookup?
Try to execute
lvMembers.beginupdate
before filling and
lvMembers.endupdate
afterwards. Better now?
And try this version: (an attempt)
Dim Items As String()
ReDim Items(reader.FieldCount - 1)
Do While reader.Read
Items(0) = CStr(reader(0))
For i = 1 To reader.FieldCount - 1
If reader.IsDBNull(i) Then
Items(i) = "" 'or String.Empty
Else
Items(i) = reader.GetString(i)
End If
Next i
itmListItem = New ListViewItem(Items)
lvmembers.Items.Add(itmListItem)
icount = icount + 1
Loop
Armin

What you want to do is if you are using ListView , make it a virtual
listview. I have samples if you need them. Can fill and display 30K items
very quickly.

LS
Jun 27 '08 #4
"Bill Schanks" <ws******@gmail.comschrieb
The error is coming because sSQL is too large, and I am getting the
error on SQL Excecution when there are 30000 entries in the in clause
of the sql command.
Reading this statement
>>Howerver on a large number of listview records this will produce a
problem (Say if I had 30,000 Listview entires)."
I thought it takes too long.
What does "SQL is too large" mean? Do you get an exception? Which one?

Armin

Jun 27 '08 #5
This is the error:
system.data.sqlclient.sqlexception: Internal query processor error:
The query processor ran out of stack space during query optimization

This is because the in clause would have 30,000+ items in it.

On Apr 25, 1:53 pm, "Armin Zingler" <az.nos...@freenet.dewrote:
"Bill Schanks" <wscha...@gmail.comschrieb
The error is coming because sSQL is too large, and I am getting the
error on SQL Excecution when there are 30000 entries in the in clause
of the sql command.

Reading this statement
>Howerver on a large number of listview records this will produce a
problem (Say if I had 30,000 Listview entires)."

I thought it takes too long.

What does "SQL is too large" mean? Do you get an exception? Which one?

Armin
Jun 27 '08 #6
"Bill Schanks" <ws******@gmail.comschrieb
This is the error:
system.data.sqlclient.sqlexception: Internal query processor error:
The query processor ran out of stack space during query optimization

This is because the in clause would have 30,000+ items in it.
Ok, I see. Just read your other message. Wondered why you posted the
code to fill the listview if it has nothing to do with the problem.
Anyways, yes, you should insert the keys into a table and have the DBMS
do the join.
Armin

Jun 27 '08 #7
Thanks. Sorry I should have been more clear in my question.

On Apr 25, 5:00 pm, "Armin Zingler" <az.nos...@freenet.dewrote:
"Bill Schanks" <wscha...@gmail.comschrieb
This is the error:
system.data.sqlclient.sqlexception: Internal query processor error:
The query processor ran out of stack space during query optimization
This is because the in clause would have 30,000+ items in it.

Ok, I see. Just read your other message. Wondered why you posted the
code to fill the listview if it has nothing to do with the problem.
Anyways, yes, you should insert the keys into a table and have the DBMS
do the join.

Armin
Jun 27 '08 #8
Bill Schanks wrote:
This is the error:
system.data.sqlclient.sqlexception: Internal query processor error:
The query processor ran out of stack space during query optimization

This is because the in clause would have 30,000+ items in it.
I have to ask, where do the 30,000 items come from? Assuming they haven't been
added manually by the user, it seems like they might already be in the DB
somewhere.

I'm surprised you could go as high as 30,000, that's a pretty big IN clause. :)

Jun 27 '08 #9
The application pulls users that are in an Active Directory Group. And
allows users to pull add'l data from the HR Records that is not avail
from Active Directory.

And it doesn't allow 30,000 records in the in clause it errors out. I
don't know what the limit is. Now 30,000 is an extreme example. Users
most likely won't want to pull info on 30,000 People. But I'd like the
app to work regardless.

On Apr 25, 8:19 pm, "Steve Gerrard" <mynameh...@comcast.netwrote:
Bill Schanks wrote:
This is the error:
system.data.sqlclient.sqlexception: Internal query processor error:
The query processor ran out of stack space during query optimization
This is because the in clause would have 30,000+ items in it.

I have to ask, where do the 30,000 items come from? Assuming they haven't been
added manually by the user, it seems like they might already be in the DB
somewhere.

I'm surprised you could go as high as 30,000, that's a pretty big IN clause. :)
Jun 27 '08 #10
Bill Schanks wrote:
The application pulls users that are in an Active Directory Group. And
allows users to pull add'l data from the HR Records that is not avail
from Active Directory.

And it doesn't allow 30,000 records in the in clause it errors out. I
don't know what the limit is. Now 30,000 is an extreme example. Users
most likely won't want to pull info on 30,000 People. But I'd like the
app to work regardless.
Got it. So they aren't in the DB. I don't know what the limit in on an IN clause
might be, but I suspect it is variable, depending on configuration and possibly
load on the server as well.

I would pick a number for the limit of one query, somewhere in the 20 to 50
range maybe. You can then run the query repeatedly, getting 20 to 50 results
each time. If you made the query with parameters, you can get pretty good
results this way; after the first one, the server caches the statement, and can
crank them out. It is a little bit like using a keyset cursor, something some of
the database drivers do - or used to do. It will help if PreferredID is indexed.

The SQL with just 3 parameters might look like
... Where PreferredID IN (@P1, @P2, @P3) ...

you would add the parameters to your command:
command.Parameters.Add("@P1", SqlDbType.VarChar, 80)
command.Parameters.Add("@P2", SqlDbType.VarChar, 80)
command.Parameters.Add("@P3", SqlDbType.VarChar, 80)

for each batch, you set the parameter values instead of building a string:
command.Parameters("@P1").Value = item.Text

and clear any unused parameters if the last batch has less than a full set.

It would take some fiddling to get it to work right, but once you have it,
something like that could handle any volume, and give a reasonable response time
as well.

The alternative, uploading the list of items to the server first, may or may not
be useful. Inserting several 1000 records is not particularly fast, but it might
work well, depending on - well, lots of things, I guess.


Jun 27 '08 #11
"Lloyd Sheen" <a@b.cwrote in message
news:OX**************@TK2MSFTNGP05.phx.gbl...
What you want to do is if you are using ListView , make it a virtual
listview. I have samples if you need them. Can fill and display 30K
items very quickly.
I don't know whether anyone from Microsoft regularly reads the Visual Basic
groups but if they do then I am very surprised that they permit one of their
own MVPs to engage in such outrageous long term trolling activities in one
of their own public newsgroups, such as the activity that the person who
purports to be Bill McCarthy has engaged in on the
microsoft.public.vb.general.discussion group for many months. If this man
belongs to you:

https://mvp.support.microsoft.com/pr...9-25680609CCB8

.. . . then perhaps you might like to look at his activity in that group.
Here for example is one of his very latest offerings:

"Bill McCarthy" <Bi**@N0SPAM.comwrote in message
news:19**********************************@microsof t.com...
Yeh, still a way to go. I think given the warm reaction today,
and given some folks have learning difficulties around here
(obviously why they are still *stuck* in VB6 *only*), might
just have to ramp things up a notch or two, and make it more
toasty :D


Jun 27 '08 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2547
by: James | last post by:
Please help - getting very desperate! Sun, 12 October 2003 05:39 I have PHPDEV 4.2.3 from Firepages.com.au as the upgrade to 4.3.0 did not work. I also had an abortive download from PHP.NET as...
7
6039
by: ivan_oj28 | last post by:
Hi, I am developing an application where I need to read the caller id from an incoming call. The only info (for now) I need is the caller id info, so that I can display the propper caller info on...
4
9154
by: Rajesh Kumar Mallah | last post by:
Hi, We need to implement following logic efficiently. SELECT * from some_table where .... IF rows_matched = 1 THEN use the single row that matched.
1
2677
by: Gunjan Garg | last post by:
Hello All, I am working to create a generic datagrid which accepts a datasource(ListData - This is our own datatype) and depending on the calling program customizes itself for sorting,...
0
1163
by: Steve | last post by:
Hi All, I have a Python script that uses SOAPpy and I'm outputting all of the methods and info about the parameters... I'm having trouble getting information out of the __init__ parameter. ...
4
1583
by: Max | last post by:
Hello, I live in Canada and I would like to get a copy of Visual Studio .NET 2005. I looked on Amazon and they don't ship to here and neither does Microsoft. I can't find any retailer that has VS...
2
1714
by: sesling | last post by:
Our Database stores event messages in a table called eventnotifications. The table has a message type column. There are two types of messages (alert or info). I have created a form that includes a...
33
11801
by: JamesB | last post by:
I am writing a service that monitors when a particular app is started. Works, but I need to get the user who is currently logged in, and of course Environment.UserName returns the service logon...
2
3546
by: rustyc | last post by:
Well, here's my first post in this forum (other than saying 'HI' over in the hi forum ;-) As I said over there: ... for a little side project at home, I'm writing a ham radio web site in...
0
2895
by: buntyindia | last post by:
Hi, I have a very strange problem with my application. I have developed it using Struts. I have a TextBox With Some fixed value in it and on Submit iam passing it to another page. <html:form...
0
7115
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7154
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7190
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6858
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7360
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5451
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3086
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3076
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
633
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.