0

lstUsers.Clear()
lstUsers.View = View.Details
lstUsers.Activation = ItemActivation.TwoClick
lstUsers.Columns.Add("First Name", 100, HorizontalAlignment.Center)
lstUsers.Columns.Add("Last Name", 100, HorizontalAlignment.Center)
lstUsers.Columns.Add("Email", 100, HorizontalAlignment.Center)
lstUsers.Columns.Add("Job Title", 100, HorizontalAlignment.Center)
lstUsers.Columns.Add("Mobile No", 100, HorizontalAlignment.Center)
'lstUsers.Columns.Add("People Involved", 100, HorizontalAlignment.Center)
Dim cnn As New OleDbConnection
Dim da As OleDbDataReader
Dim cmd1 As New OleDbCommand
cnn.ConnectionString = "Provider=Microsoft.JET.OLEDB.4.0;DATA SOURCE=c:\ApptDB.mdb"
cnn.Open()
cmd1.Connection = cnn
cmd1.CommandText = "select confirstname,conlastname,conemail,conjobtitle,conmobilenum from continfo where conusername = '" & anc & "' order by confirstname asc"
da = cmd1.ExecuteReader()
Do While da.Read
Dim itmp1 As New Windows.Forms.ListViewItem(da.GetString(0), 0)
Dim itms2 As New Windows.Forms.ListViewItem.ListViewSubItem(itmp1, da.GetValue(1))
Dim itms3 As New Windows.Forms.ListViewItem.ListViewSubItem(itmp1, da.GetValue(2))
Dim itms4 As New Windows.Forms.ListViewItem.ListViewSubItem(itmp1, da.GetValue(3))
Dim itms5 As New Windows.Forms.ListViewItem.ListViewSubItem(itmp1, da.GetValue(4))
itmp1.SubItems.Add(itms2)
itmp1.SubItems.Add(itms3)
itmp1.SubItems.Add(itms4)
itmp1.SubItems.Add(itms5)
lstUsers.Items.Add(itmp1)
Loop
cnn.Close()


i need to fix the (order by statement) to have the names alphabtically

2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by Ravi Singhal
0

lstUsers.Clear()
lstUsers.View = View.Details
lstUsers.Activation = ItemActivation.TwoClick
lstUsers.Columns.Add("First Name", 100, HorizontalAlignment.Center)
lstUsers.Columns.Add("Last Name", 100, HorizontalAlignment.Center)
lstUsers.Columns.Add("Email", 100, HorizontalAlignment.Center)
lstUsers.Columns.Add("Job Title", 100, HorizontalAlignment.Center)
lstUsers.Columns.Add("Mobile No", 100, HorizontalAlignment.Center)
'lstUsers.Columns.Add("People Involved", 100, HorizontalAlignment.Center)
Dim cnn As New OleDbConnection
Dim da As OleDbDataReader
Dim cmd1 As New OleDbCommand
cnn.ConnectionString = "Provider=Microsoft.JET.OLEDB.4.0;DATA SOURCE=c:\ApptDB.mdb"
cnn.Open()
cmd1.Connection = cnn
cmd1.CommandText = "select confirstname,conlastname,conemail,conjobtitle,conmobilenum from continfo where conusername = '" & anc & "' order by confirstname asc"
da = cmd1.ExecuteReader()
Do While da.Read
Dim itmp1 As New Windows.Forms.ListViewItem(da.GetString(0), 0)
Dim itms2 As New Windows.Forms.ListViewItem.ListViewSubItem(itmp1, da.GetValue(1))
Dim itms3 As New Windows.Forms.ListViewItem.ListViewSubItem(itmp1, da.GetValue(2))
Dim itms4 As New Windows.Forms.ListViewItem.ListViewSubItem(itmp1, da.GetValue(3))
Dim itms5 As New Windows.Forms.ListViewItem.ListViewSubItem(itmp1, da.GetValue(4))
itmp1.SubItems.Add(itms2)
itmp1.SubItems.Add(itms3)
itmp1.SubItems.Add(itms4)
itmp1.SubItems.Add(itms5)
lstUsers.Items.Add(itmp1)
Loop
cnn.Close()


i need to fix the (order by statement) to have the names alphabtically

Hi

Use the following

cmd1.CommandText = "select confirstname,conlastname,conemail,conjobtitle,conmobilenum from continfo where conusername = '" & "anc" & "' order by confirstname asc"

just use quote sign with "anc"

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.