我是 webservice 的新手,我在下面尝试做的是在方法中传递变量并从类中的不同表中从 sql 获取数据......但是对于某些运行此代码时,我看不到我的 webmethod。 ..任何帮助都非常感谢..当我被卡住并且明天必须交付一些东西时,越快越好...
namespace Webdata
{
public class Data : System.Web.Services.WebService
{
class Record
{
public Char DESCRPTN_104 { get; set; }
public Char PMDES_01 { get; set; }
public Char PRTNUM_10 { get; set; }
public Char ORDRef_10 { get; set; }
public DateTime TNXDTE_01 { get; set; }
[WebMethod]
static List<Record> GetData(string ORDNUM_10)
{
SqlConnection con = new SqlConnection(@"Data Source=****;Initial Catalog=******;Integrated Security=true;");
con.Open();
SqlCommand cmd = new SqlCommand("SELECT DISTINCT Account_Types.DESCRPTN_104, Part_Master.PMDES1_01,Order_Master.PRTNUM_10,Order_Master.ORDNUM_10,Order_Master.ORDRef_10,Part_Master.TNXDTE_01 FROM (****.dbo.Order_Master Order_Master LEFT OUTER JOIN ****.dbo.Part_Master Part_Master ON Order_Master.PRTNUM_10=Part_Master.PRTNUM_01) LEFT OUTER JOIN ****.dbo.Account_Types Account_Types ON Part_Master.ACTTYP_01=Account_Types.ACTTYP_104 WHERE Order_Master.ORDNUM_10 = '" + ORDNUM_10 + "'", con);
SqlDataReader dr = cmd.ExecuteReader();
List<Record> records = new List<Record>();
while (dr.Read())
{
records.Add(new Record()
{
DESCRPTN_104 = dr.GetChar(0),
PMDES_01 = dr.GetChar(1),
PRTNUM_10 = dr.GetChar(2),
ORDRef_10 = dr.GetChar(3),
TNXDTE_01 = dr.GetDateTime(4)
});
}
dr.Close();
con.Close();
return records;
}}
}
}