正 文

从Web Service中返回一个SqlConnection部件出错


www.7dspace.com  更新日期:2005-12-16 5:44:03  七度空间


关于从Web Service中返回一个SqlConnection部件出错的问题,代码如下:

    private  SqlConnection Cn=null;
    private  SqlConnection AccCn=null;
    [WebMethod]
    public SqlConnection AppCn(String AccNo)
    {
        if (Cn != null)
            return;// Cn;
        if (AccNo == null)
        {
            SqlCommand com = new SqlCommand("select * from AppAccount Where AccNo='" + AccNo + "'", AccCn);
            SqlDataReader mreader = com.ExecuteReader();
            mreader.Read();
            String Connect_Str = "Data Source=" + mreader["AccServer"].ToString() + ";Initial Catalog=" + mreader["AccDataBase"].ToString();
            Connect_Str = Connect_Str + ";Persist Security Info=True;User ID=" + mreader["AccUser"].ToString() + ";Password=" + mreader["AccPassword"].ToString();
            Cn = new SqlConnection(Connect_Str);
        }
        else
        {
            Cn = new SqlConnection();
            Cn.ConnectionString = AccCn.ConnectionString;
        }
        Cn.Open();
        return Cn;
    }

错误:

Cannot serialize member System.ComponentModel.Component.Site of type System.ComponentModel.ISite because it is an interface.

该如何解决啊?

SqlConnection 不能被序列化,所以不能通过webservice 返回


上一篇:所有链接都设成_blank简单方法
下一篇:Windows路由表透析
作者:  来源:Techtarget ( 责任编辑:7dspace )
收藏此页】【打印】【关闭
站 内 搜 索
 

热 点 导 读
特 别 推 荐