Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Generic list in ASP.NET
WhatsApp
Igor Djuricic
Jul 20
2016
1.2
k
0
1
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;
}
asp.net
c#
Up Next
Generic list in ASP.NET