views:

241

answers:

1

Hi there,

I am trying use a datatable from a web service method. I can see return value when it's a string data. This my code and it returns an alert hatada : null

 $.ajax(
            {
                type: 'POST',
                url: 'http://localhost:40764/HastaTahlilUyariServisi.asmx/Hello',
                data: "{_sTcKimlikNo: '111111111111', _iKlinikKodu:121212, _bAy:12, _iYil:2009}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function(ajaxCevap) {
                    alert('basarili: ' + ajaxCevap); //$('#dv').html(ajaxCevap.d);
                },
                error: function(xhr, status) {                   
                    alert("hatada:" + xhr.responseXML);
                },
                beforeSend: function() {
                    alert('gonderilecek');
                },
                afterSend: function() {
                    alert('gonderildi');
                },
                complete: function(xhr, status) {
                    if (status == 'success')
                        alert('success' + $.httpData(xhr));
                }
            }

and this is my webservice method:

  [WebMethod]
    public DataTable Hello(string _sTcKimlikNo, int _iKlinikKodu, byte _bAy, int _iYil)
    {
        DataTable dt = new DataTable();
        dt.Columns.Add("ad");
        DataRow rw = dt.NewRow();
        rw[0] = _sTcKimlikNo + " " + _iKlinikKodu + " " + _bAy + " " + _iYil;
        return dt;
    }

How can i see datatable from webservice method? Thanks in advance.

A: 

I don't think you can return a DataTable from a web service due to serialisation problems. This Microsoft article suggests returning a DataSet instead:
Problems using an XML Web service that returns a DataTable

Andy Rose