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
Faisal Ansari
NA
451
831.7k
How can we create Web Service with Database
Aug 15 2011 6:05 AM
hello guys how r u ?
my question is that,
i am creating a web service which is fetching data from database and retrive to client,
my code is below
Web service file
---------------
[WebMethod]
public DataTable DataService()
{
SqlConnection con = new SqlConnection(@"Data Source=HIDAYA2-PC; Integrated Security=True; Database=ProjectTestDB;");
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.Connection.Open();
cmd.CommandText = "select * from Person";
SqlDataReader reader = cmd.ExecuteReader();
DataTable dt = new DataTable();
if (reader.HasRows)
{
dt.Load(reader);
}
cmd.Connection.Close();
return dt;
}
Default.aspx.cs
---------------
protected void Page_Load(object sender, EventArgs e)
{
WebService1.Service service = new WebService1.Service();
GridView1.DataSource = service.DataService();
GridView1.DataBind();
}
my problem is that an exception accured over there
reply soon
thanks.
Reply
Answers (
5
)
Unable to call HttpWebResponse.GetResponse() method from web service
How to create a webservice for iphone