1)Create Class File and Give Name "Funcation"
2)Past Code in class file "Funcation"
2)Past Code in class file "Funcation"
public static void listview(ListView lst, string sql, SqlConnection sqlConnection)
{
SqlCommand cmd = new SqlCommand(sql, datastore.Connection());
SqlDataReader dr = cmd.ExecuteReader();
ListViewItem itmX;
while (dr.Read())
{
itmX = new ListViewItem();
itmX.Text = dr.GetValue(0).ToString();
for (int i = 1; i < dr.FieldCount; i++)
{
itmX.SubItems.Add(dr.GetValue(i).ToString());
}
lst.Items.Add(itmX);
}
dr.Close();
datastore.CloseConnection();
}
3) past following code in project button event
private void button2_Click(object sender, EventArgs e)
{
lstworklist.Items.Clear();
function.listview(lstworklist, "select * from Specification", datastore.Connection());
}
1 comments:
Thank you for sharing your info. I truly appreciate your efforts and I am waiting for your next post thank you once again.
app development services provider in islamabad
Post a Comment