I have 3 questions need help ,please

1- in windows application datagridview doesn't show data ,although the code is correct 100% and I tried the code in gridview in web app and it worked properly .

and when I tried to bind data to datagridview wizard it worked .

I tried a very simple query to ensure the datagridview is doesn't work

 SqlCommand cmd = new SqlCommand("select dep from department", con); 
con.Open();
 SqlDataReader read = cmd.ExecuteReader(); 
dataGridView1.DataSource = read;
 con.Close(); 

2- how can I run a deployed windows app connected to sql server database in a pc without need to setup sql server management studio

3- how to make windows app trial and work after entering specific serial no

thanks in advance

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top