TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Generic list in ASP.NET
Igor Đuričić
Jul 20
2016
Code
1
k
0
1
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
protected
List<DbBroker> getArr()
{
String query = (Session[
"UserName"
] !=
null
) ? Session[
"UserName"
].ToString() : String.Empty;
S
tring
squery = (Session[
"Product"
] !=
null
) ? Session[
"Product"
].ToString() : String.Empty;
DbBroker db =
new
DbBroker();
SqlConnection sc =
new
SqlConnection(db.conn());
sc.Open();
SqlCommand cmd =
new
SqlCommand(db.executeQuery(), sc);
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue(
"@nameu"
, query);
cmd.Parameters.AddWithValue(
"@name"
, squery);
SqlDataReader dr = cmd.ExecuteReader();
while
(dr.Read())
{
db.Name = dr.GetString(0);
db.UserName = dr.GetString(1);
db.Bidvalue = Convert.ToInt32(dr.GetInt32(2));
result.Add(db);
}
sc.Close();
return
result;
}
c#
asp.net