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
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
manikandan r
NA
358
0
How to use Static method in 3 tier Architecture
May 18 2018 5:10 PM
Hi,
Can someone guide me how to Split this below static webmethod into 3 tier architecture? (DAL, BAL and UI)
[
WebMethod
]
public
static
string
[] GetCustomers(
string
prefix)
{
List
<
string
> customers =
new
List
<
string
>();
using
(
SqlConnection
conn =
new
SqlConnection
())
{
conn.ConnectionString =
ConfigurationManager
.ConnectionStrings[
"constr"
].ConnectionString;
using
(
SqlCommand
cmd =
new
SqlCommand
())
{
cmd.CommandText =
"select ContactName, CustomerId from Customers where ContactName like @SearchText + '%'"
;
cmd.Parameters.AddWithValue(
"@SearchText"
, prefix);
cmd.Connection = conn;
conn.Open();
using
(
SqlDataReader
sdr = cmd.ExecuteReader())
{
while
(sdr.Read())
{
customers.Add(
string
.Format(
"{0}-{1}"
, sdr[
"ContactName"
], sdr[
"CustomerId"
]));
}
}
conn.Close();
}
}
return
customers.ToArray();
}
Reply
Answers (
1
)
Currency ConversionAPI
How to retrieve an actionlink text in a controller?