ListView SQL DB Problem

A

aBsenT

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.CloseConnection)
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
 
V

Valeria Galvano

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top