01.
using
System;
02.
using
System.Collections.Generic;
03.
using
System.Linq;
04.
using
System.Web;
05.
using
System.Web.Services;
06.
using
System.Configuration;
07.
using
System.Data.SqlClient;
08.
using
System.Data;
09.
using
System.ComponentModel;
10.
using
System.Web.Services.Protocols;
11.
using
System.Xml.Linq;
12.
using
System.Web.Configuration;
13.
14.
16.
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
17.
18.
19.
public
class
Service : System.Web.Services.WebService
20.
{
21.
22.
23.
public
Service () {
24.
25.
26.
27.
}
28.
29.
[WebMethod]
30.
public
string
HelloWorld() {
31.
return
"Hello World"
;
32.
}
33.
[WebMethod]
34.
public
string
ShowNameAndLastName(
string
name,
string
lastname)
35.
{
36.
string
name_str = name;
37.
string
lastname_str = lastname;
38.
39.
return
string
.Format(
"สวัสดีครับคุณ"
+ name_str +
" "
+ lastname_str +
"เป็นอย่างไรบ้าง"
);
40.
41.
42.
}
43.
[WebMethod]
44.
public
string
ConnectDB()
45.
{
46.
47.
48.
49.
50.
string
connection13 = ConfigurationManager.ConnectionStrings[
"sql"
].ConnectionString;
51.
SqlConnection ceConn =
new
SqlConnection(connection13);
52.
SqlCommand ceCmd = ceConn.CreateCommand();
53.
ceCmd.CommandType = CommandType.Text;
54.
ceCmd.CommandText =
"select*from customer "
;
55.
56.
57.
System.Data.DataSet _Ds1 =
new
System.Data.DataSet();
58.
SqlDataAdapter _npgAdap =
new
SqlDataAdapter(ceCmd);
59.
_npgAdap.Fill(_Ds1,
"moo"
);
60.
61.
return
_Ds1;
62.
63.
}
64.
65.
}