473,396 Members | 1,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

ListView SQL DB Problem

I'm trying to bind a listview based on values in a treeview that has
letters of the alphabet as refrences. The code for the listview is as
follows :

'populate listbox

SqlCommand2.CommandText = " Where ClientName Like'" &
entry_letter & "%'"
SqlCommand2.Connection.Open()
myrdr = SqlCommand2.ExecuteReader(CommandBehavior.CloseCon nection)
ListView1.Items.Clear()
Dim lstAdd As ListViewItem
i = 0
ListView1.Columns.Add("Name", 140, HorizontalAlignment.Left)
ListView1.Columns.Add("Address", 70, HorizontalAlignment.Left)
ListView1.Columns.Add("Phone", 70, HorizontalAlignment.Left)
Do While myrdr.Read
node_key = myrdr.GetString(1) & ", " & myrdr.GetString(2)
ListView1.Items(i).SubItems.Add(myrdr.GetString(3) )
ListView1.Items(i).SubItems.Add(myrdr.GetString(5) )
i += 1
Loop
myrdr.Close()

when I run a compile I get an Error : An unhandled exception of type
'System.Data.SqlClient.SqlException' occurred in system.data.dll

Additional information: System error.

I am new to VB.net and SQL server connections. If someone could either
point out my error in the code, or point me in the right way for an
example - Greatly appreciated.

thanx
aBsenT
Nov 20 '05 #1
1 3521
I'm new too, but your commandtext seems to be incomplete. I don't know if is
correct but I think that you forgot the Select statement with the table name
...
Let me know, I need to learn too.
Regards
Valeria

"aBsenT" <sl********@hotmail.com> ha scritto nel messaggio
news:9f**************************@posting.google.c om...
I'm trying to bind a listview based on values in a treeview that has
letters of the alphabet as refrences. The code for the listview is as
follows :

'populate listbox

SqlCommand2.CommandText = " Where ClientName Like'" &
entry_letter & "%'"
SqlCommand2.Connection.Open()
myrdr = SqlCommand2.ExecuteReader(CommandBehavior.CloseCon nection)
ListView1.Items.Clear()
Dim lstAdd As ListViewItem
i = 0
ListView1.Columns.Add("Name", 140, HorizontalAlignment.Left)
ListView1.Columns.Add("Address", 70, HorizontalAlignment.Left)
ListView1.Columns.Add("Phone", 70, HorizontalAlignment.Left)
Do While myrdr.Read
node_key = myrdr.GetString(1) & ", " & myrdr.GetString(2)
ListView1.Items(i).SubItems.Add(myrdr.GetString(3) )
ListView1.Items(i).SubItems.Add(myrdr.GetString(5) )
i += 1
Loop
myrdr.Close()

when I run a compile I get an Error : An unhandled exception of type
'System.Data.SqlClient.SqlException' occurred in system.data.dll

Additional information: System error.

I am new to VB.net and SQL server connections. If someone could either
point out my error in the code, or point me in the right way for an
example - Greatly appreciated.

thanx
aBsenT

Nov 20 '05 #2

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

Similar topics

0
by: Steph. | last post by:
I use a ListView in a form to display Data from an SQL db. My problem is that I can fill the listview in less than a second when I show the form AFTER filling the listview, but I take 35...
15
by: Wiktor Zychla | last post by:
today we've found a critical issue regarding the ListView from Windows.Forms. it was confirmed on several machines with Win2K and XP. here's the problem: create a ListView with about 50000 rows....
0
by: Sérgio Almeida | last post by:
Greetings I have a problem using listview control. Well, I belive that this is not realy a problem, but it's consuming me precious time. Here is the scenario (an example of my problem). I...
3
by: MikeY | last post by:
Hopefully someone can help me on this. I am using C#, making Windows forms. I have created a listView with checkbox's. I have enabled the checkboxes under the properties, and all the data,...
4
by: firefox | last post by:
Hola Foro!, tengo una rutina que permite agregar varios elementos o items de una sola vez en un ListView. Lo que sucede es que en el momento que se añaden los items al ListView se pone todo blanco,...
4
by: Pucca | last post by:
How can I tell a mouse right clicks over a listview item that's in a container panel. I only want to display a popup menu if the user right click the mouse over an item on the Listview. I don't...
3
by: Martin Panggabean | last post by:
Hello All, I've kind a logic problem ... I want to fill the listView control in VB.NET with data in my mySql table using Datareader object component. But It seems that the way of how listView...
12
by: garyusenet | last post by:
I have had no replies to my previous post so perhaps I didn't write it good enough. Please excuse new thread but i wanted to break from the last thread hopefully this thread will be better. ...
4
by: Brian Gaze | last post by:
I have created a ListView control and have bound this to a datasource. Within the ItemTemplate of the ListView I have added another ListViewControl which is databound in the code behind. The idea...
2
by: =?Utf-8?B?UGhpbGlw?= | last post by:
I am attempting to insert a simple record with LinqDataSource from a ListView, however I always get a message saying "....LinqDataSource 'dataSource' has no values to insert. Check that the...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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...
0
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
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...

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.