Click here to Skip to main content
15,886,055 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Error

Type 'System.Data.SqlTypes.SqlString' with data contract name 'string:http://www.w3.org/2001/XMLSchema' is not expected. Consider using a DataContractResolver or add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.

client code
C#
protected void btnnextpersdetls_Click(object sender, EventArgs e)
    {
SqlParameter[] _params = { new SqlParameter("@UserName","kotlanaveen23@gmail.com"),new SqlParameter("@password","xswqaz")};
DataSet ds1 = new DataSet();
ds1 = objl.fnExecuteDataSet("hrrec", "T", "sp_GetEmpPersonalDetails", _params);
}


service method

public DataSet fnExecuteDataSet(string schema, string connect_Test_or_Production, string p, params SqlParameter[] Parameters)
    {
        // throw new NotImplementedException();
        try
        {
            if (fnOpenConnection(schema, connect_Test_or_Production) == true)
            {
                _objDataSet = new DataSet();
                _objSqlDataAdapter = new SqlDataAdapter();
                _objSQLCommand = new SqlCommand();

                _objSQLCommand.Connection = _objSQLConnection;
                _objSQLCommand.CommandType = CommandType.StoredProcedure;
                _objSQLCommand.CommandText = p;

                foreach (SqlParameter objParamaeter in Parameters)
                {
                    _objSQLCommand.Parameters.Add(objParamaeter);
                }

                _objSqlDataAdapter.SelectCommand = _objSQLCommand;
                _objSqlDataAdapter.Fill(_objDataSet);

                return _objDataSet;
            }
            else
            {
                return null;
            }
        }
        catch (SqlException dbEx)
        {
            return null;
        }
        catch (Exception ex)
        {
            return null;
        }
        finally
        {
            _objDataSet = null;
            _objSqlDataAdapter = null;
            _objSQLCommand = null;
            fnCloseConnection();
        }
    }
Posted
Comments
Kornfeld Eliyahu Peter 24-Dec-14 6:29am    
Can you show your data contract? You probably missing a KnownType declaration there...
Praveen Kumar Upadhyay 24-Dec-14 6:43am    
Is fnExecuteDataSet your WebMethod?

1 solution

You should probably redesign your WCF inputs to use a Fly Weight object to encapsulate the information that you want to send to the service call and not send SqlParameter objects. This way you are also not just tied to MS SQL specific calls.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900