Click here to Skip to main content
15,922,584 members

Comments by kashishh (Top 8 by date)

kashishh 24-Oct-14 4:57am View    
Deleted
it works ... Thanku so much :-)
kashishh 23-Oct-14 11:52am View    
Deleted
Thanks. but that's giving the tables from the master database I guess. can I give database name tooo in this query or somehow to get the tables count from that specific database.?
kashishh 23-Oct-14 11:33am View    
Deleted
no tables in it.
kashishh 15-Oct-14 10:47am View    
Deleted
//Windows form

private void btn_Click(object sender,EventArgs e)
{
GetPersons();

}

private static void GetPersons()
{
List Modules = new List();
Modules = Persons.CheckPersonsData(); //this line of code is giving exception : ex = {"The type initializer threw an exception."} I need to call CheckPersonsData method and get the list values


}


//Class Persons .Below method is working fine

public static List<string> CheckPersonsData()
{
List<string> _lstPersons = new List<string>();
string Name=string.Empty;

using(SqlConnection conn = new SqlConnection(TestConn))

{
using(SqlCommand cmd = new SqlCommand("select [Name] from [Persons]",conn))
{
conn.Open();
using(SqlDataReader dr = cmd.ExecuteReader())
{
if(dr.HasRows)
{
while(dr.Read())
{
{
Name = dr.GetString(dr.GetOrdinal("Name"));
};

_lstPersons.Add(Name);
}
}

dr.Close();
}
return _lstPersons;
}
}
}
kashishh 15-Oct-14 10:16am View    
Deleted
This is the method which I want to call :

public static List CheckDataAccess()
{


List _lstPerson = new List();
string Name = string.Empty;

using(SqlConnection conn = new SqlConnection(testconn))

{
using(SqlCommand cmd = new SqlCommand("select [Name] from [Persons]",conn))
{
conn.Open();
using(SqlDataReader dr = cmd.ExecuteReader())
{
if(dr.HasRows)
{
while(dr.Read())
{
{
Name = dr.GetString(dr.GetOrdinal("Name"));
};

_lstPerson.Add(Name);
}
}

dr.Close();
}
return _lstPerson;
}
}
}