Hello,

I have a listbox w/ names of SQL Server 2000 fields loaded into it.
I looped through the listbox to include square brackets [ ] incase the fields have a blank.

Here is my code:

VB Code:
  1. Dim i As Integer
  2. strSQL = "SELECT Toc.Name AS [Document Name], "
  3.                 For i = 0 To lstSelection.Items.Count - 1
  4.                     lstSelection.SelectedIndex = i  'Read through list box
  5.                         strSQL &= "[" & lstSelection.Items(i).ToString & "]" & ", "
  6.      
  7.                 Next
  8.                'Removes the last comma
  9.  
  10.                 strSQL = strSQL.Substring(0, strSQL.Length - 2)

Is there a way to tell which field is a SQL Server datetime field automatically then grab that field and do a:

VB Code:
  1. strSQL &= "CONVERT(VARCHAR(10), " & "[" & lblSelectedDate.Text & "]" & ", 101) AS " 'Whatever the datetime field is

(That cuts off the time in the field)

Thanks!

Chris