I have a button code that passes data from a connectionString to a listBoxDat:
private void btnClick_Click(object sender, RoutedEventArgs e)
{
tbTitle.Text = "ADO.Net";
listBoxData.Background = Brushes.LemonChiffon;
string cs = ConfigurationManager.ConnectionStrings["crams"].ConnectionString;
List<string> titles = new List<string>();
using (SqlConnection conn = new SqlConnection(cs))
{
conn.Open();
SqlCommand cmd = conn.CreateCommand();
cmd.CommandText = "Select filenum FROM dbo.Complaint";
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
titles.Add(reader.GetString());
}
listBoxData.ItemsSource = titles;
}
}
My error list keeps saying that there is No overload for method 'Get sTring' takes 0 arguments. I am not sure what this means!