添加web引用就可以得到webservice的对象了

解决方案 »

  1.   

    在Web Service里:
    [WebMethod]
    public DataSet GetData()
    {
        //提取数据
        DataSet ds = new DataSet()
        ds = GetDataFromDataBase();
        return ds;
    }
    [WebMethod]
    public void SaveData(DataSet ds)
    {
        //返回,保存数据 
        SaveDataToDataBase(ds);   
    }然后在前端对这个Web Service调用,使用相应的方法。
      

  2.   

    ds = GetDataFromDataBase();GetDataFromDataBase();是什么函数,提示出错,我找不到这个函数
      

  3.   

    我想GetDataFromDataBase();应该是自己写的函数; 同样,SaveDataToDataBase(ds); 也是
      

  4.   

    webservice如下: [WebMethod]

    public DataSet getdata()
    {
    DataSet ds=new DataSet1 (); return ds;
    }前端有getdate()可以引用,但邦定到DateGrid时反回的只有表头(结构)没有记录.
      

  5.   

    //一个简单例子
    using System.Data;
    using System.Data.OleDb;public class db{
    [WebMethod]
    public DataSet getdata(){
    string tabname="admin";
    DataSet ds;
    string sql="SELECT * FROM "+ tabname;
    string constr="provider=Microsoft.jet.OLEDB.4.0;data Soruce="+ Server.MapPath("db.mdb")+";";OleDbConnection odc = new OleDbConnection(constr);
    odc.Open();OleDbDataAdapter da=new OleDbDataAdapter (sql,odc);
    da.Fill(ds,tabname);odc.Close();
    return ds;
    }
    }
      

  6.   

    前端要怎么调用呢?例如我要邦定到DataGrid,我用如下程序总出错。
    private void Button1_Click(object sender, System.EventArgs e)
         {
               localhost4.Service1 c=new tempconvertclient1.localhost4.Service1 ();          this.DataGrid1 .DataSource =c.getdata ();
              this.DataGrid1 .DataMember ="exchange_rate";
     this.DataGrid1 .DataBind ();
          }
      

  7.   

    对不起,是我没有写清楚,那两个方法都是自定义的,一般在都会有数据访问层和业务层来封装数据库的操作和业务然后用Web Service来调用,所以到了Web Service 已经是封装的差不多的了,上面的自定义方法就是已经封装到了只返回一个DataSet,然后由Web Service来进行调用,公布。以上只是个人的一些想法,希望大家有好的设计方案一起讨论