The code isn't 100% correct. You can't, and shouldn't, bind to a DataReader
. Consider the modified code:
using (SqlConnection con = new SqlConnection(cString))
using (SqlCommand cmd = new SqlCommand("select dep from department", con))
{
var dt = new DataTable();
dt.Load(cmd.ExecuteReader());
dataGridView1.DataSource = dt;
}
how can I run a deployed windows app connected to sql server database in a pc without need to setup sql server management studio
You just need to install SQL Express. There's a download for it and the installation is straight forward.
how to make windows app trial and work after entering specific serial no
Do some research on your own, get some code off of a post somewhere, and if you are struggling with that then come back here with some specifics and ask a new question.