15,922,584 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Visual Basic questions
View Javascript questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
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;
}
}
}
kashishh
15-Oct-14 10:08am
View
Deleted
Thanks. But I have tried calling it this way from a method of windows form, still giving error:
private static void GetPersons()
{
List<string> Modules = new List<string>();
Modules = Persons.CheckPersonsData();
}
kashishh
15-Oct-14 9:40am
View
Deleted
This is the method which I want to call from button click :
public static List<string> CheckDataAccess()
{
List<string> _lstPerson = 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"));
};
_lstPerson.Add(Name);
}
}
dr.Close();
}
return _lstPerson;
}
}
}
kashishh
15-Oct-14 9:27am
View
Deleted
I am calling A.ABC().it was just to make it more understandable.sorry for the confusion.
Show More