ex.
A 01/01/2011
B 01/01/2011
C 01/01/2011
D 01/01/2011
A 01/02/2011
B 01/02/2011
D 01/02/2011
A 01/03/2011
D 01/03/2011
The query were planning to use ?
SELECT DISTINCT Alphabets,
dateReceive FROM
database
ORDER BY Alphabets
using List
Our expected output
[{A,B,C,D},{A,B,D},{A,D}
Source code:
using (var conn = new SqlConnection("Data Source=SERV-PC\MSQLSERVER;Initial Catalog=MyDatabase;Integrated Security=True"))
{
using (var cmd = new SqlCommand())
{
cmd.Connection = conn;
cmd.CommandText = "SELECT DISTINCT [ColumnA], [DateReceive] FROM [MyDatabase].[dbo].[dummy] WHERE [ColumnA]=@loca AND [DateReceive] BETWEEN '01/01/2013' and '01/07/2013' ";
cmd.Parameters.AddWithValue("@loca", DropDownList1.SelectedValue.ToString());
conn.Open();
using (var reader = cmd.ExecuteReader())
{
while (reader.Read())
{
var tmp = reader["ColumnA"];
if (tmp != DBNull.Value)
{
ListBox1.Items.Add(reader["ColumnA"].ToString());
}
}
}
}
}
hope anyone here can help us
thanks
It looks like you're new here. If you want to get involved, click one of these buttons!