NET WebService的创建部署运用

发布时间 : 星期日 文章NET WebService的创建部署运用更新完毕开始阅读

//用户查询得到的将是myDataSet. DataSet myDataSet = new DataSet(); try {

SqlDataAdapter myAdapter = new SqlDataAdapter(); if (mvpguid != \ {

//按照用户输入的mvpguid进行查询.

myAdapter.SelectCommand = new SqlCommand(\MVPGUID='\

SqlCommandBuilder myCB = new SqlCommandBuilder(myAdapter); myAdapter.Fill(myDataSet, \ //建立表间关系.

SqlDataAdapter myAdapter1 = new SqlDataAdapter(\

OtherCompetencies.OtherCompetencies_Id,OtherCompetencies.MVP_Id from MVP,OtherCompetencies where MVP.MVP_Id=OtherCompetencies.MVP_Id and MVP.MVPGUID='\

SqlCommandBuilder myCB1 = new SqlCommandBuilder(myAdapter1); myAdapter1.Fill(myDataSet, \ SqlDataAdapter myAdapter2 = new SqlDataAdapter(\

OtherCompetency.OtherCompetencies_Id,OtherCompetency.OtherCompetency_Text from MVP,OtherCompetencies,OtherCompetency where MVP.MVP_Id=OtherCompetencies.MVP_Id and

OtherCompetencies.OtherCompetencies_Id=OtherCompetency.OtherCompetencies_Id and MVP.MVPGUID='\

SqlCommandBuilder myCB2 = new SqlCommandBuilder(myAdapter2); myAdapter2.Fill(myDataSet, \

SqlDataAdapter myAdapter3 = new SqlDataAdapter(\

Publications.Publications_Id,Publications.MVP_Id from Publications,MVP where MVP.MVP_Id=Publications.MVP_Id and MVP.MVPGUID='\ SqlCommandBuilder myCB3 = new SqlCommandBuilder(myAdapter3); myAdapter3.Fill(myDataSet, \

SqlDataAdapter myAdapter4 = new SqlDataAdapter(\

Publication.Publications_Id,Publication.Id,Publication.Title,Publication.Publisher,Publication.DatePublished,Publication.Abstract,Publication.UrlLink from

MVP,Publications,Publication where MVP.MVP_Id=Publications.MVP_Id and Publications.Publications_Id=Publication.Publications_Id and MVP.MVPGUID='\mvpguid + \

SqlCommandBuilder myCB4 = new SqlCommandBuilder(myAdapter4); myAdapter4.Fill(myDataSet, \ //Create DataRelation, and add it to the DataSet.

DataRelation dr = new DataRelation(\myDataSet.Tables[\

myDataSet.Tables[\

DataRelation dr1 = new DataRelation(\myDataSet.Tables[\ [\

myDataSet.Tables[\ DataRelation dr2 = new DataRelation(\myDataSet.Tables[\ [\

DataRelation dr3 = new DataRelation(\myDataSet.Tables[\

myDataSet.Tables[\

//获取或设置一个指示DataRelation对象是否嵌套的值. dr.Nested = true; dr1.Nested = true; dr2.Nested = true; dr3.Nested = true;

//创建关系到集合中

myDataSet.Relations.Add(dr); myDataSet.Relations.Add(dr1); myDataSet.Relations.Add(dr2); myDataSet.Relations.Add(dr3); } }

catch (SqlException exception) {

return DataError(exception); }

return myDataSet; }

//====================错误信息======================= public DataSet DataError(Exception ex) {

DataSet errDS = new DataSet(\

DataTable errTable = errDS.Tables.Add(\ errTable.Columns.Add(\

errTable.Rows.Add(new Object[] { ex.Message });

return errDS; }

代码有点多,呵呵,然后你在客户端只要引用它的接口就可以了,这样会更好理解一点,代码如下:

//====================客户端查询函数===================== protected void btnSearch_Click1(object sender, EventArgs e) {

string c_mvpGuid = \ try {

c_mvpGuid = this.txtByMVPGUID.Text.ToString(); //getDataSet对象获得查询返回的ds.

DataSet getDataSet = myService.searchData(c_mvpGuid);

///查询默认显示为MVP表.测试的时候在index.aspx页面上显示. this.dgResult.DataSource = getDataSet.Tables[\ this.dgResult.DataBind(); }

catch (Exception ex) {

throw ex; } }

要是有什么不懂的地方,你可以留言,我会给你答复。^_^

呵呵,忘了一件事,如果你用自己的xml文件,自己的数据库,那就没事了,不是的话看看:

联系合同范文客服:xxxxx#qq.com(#替换为@)