Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/228.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android中从SQL数据库检索数据的最佳方法_Android_Asp.net_Sql_Web Services - Fatal编程技术网

Android中从SQL数据库检索数据的最佳方法

Android中从SQL数据库检索数据的最佳方法,android,asp.net,sql,web-services,Android,Asp.net,Sql,Web Services,我在使用Asp.NETWebService使用SOAP方法从Android应用程序中的SQL数据库检索数据。 我也见过JSON方法,但它使用的是php。 哪种方法最好???我有Windows Server和SQL数据库,所以我只使用Asp.NET web服务。如果你有SQL Server,意味着你可以使用Asp.NET Json web服务。Json非常容易解析,我自己也只使用Json格式的.NETWebService 解析对于移动开发人员来说既快又容易 public class Employe

我在使用Asp.NETWebService使用SOAP方法从Android应用程序中的SQL数据库检索数据。 我也见过JSON方法,但它使用的是php。
哪种方法最好???我有Windows Server和SQL数据库,所以我只使用Asp.NET web服务。

如果你有SQL Server,意味着你可以使用Asp.NET Json web服务。Json非常容易解析,我自己也只使用Json格式的.NETWebService

解析对于移动开发人员来说既快又容易

public class Employee
{
    public string Name { get; set; }
    public string Company { get; set; }
    public string Address { get; set; }
    public string Phone { get; set; }
    public string Country { get; set; }
}
然后在Webserice中添加以下方法

我们将主要使用的Json数组对象

     [WebMethod]
     [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
     public static string GenerateTopicListToJSon()
            {
                try

                {

                    //Do ur query in GetMethod() to retrieve from DB     
                    List<Employee> lstEmployee = GetMethod();
                    var topic = from t in lstEmployee
                                select new
                                {
                                    Name= t.TopicID,
                                    Company = t.Company,
                                    Address = t.Address,
                        Phone = t.Phone,
                                    Country = t.Country

                                };


                    var oSerializer = new System.Web.Script.Serialization.JavaScriptSerializer();
                    return oSerializer.Serialize(topic);

                }
希望它能帮助你,老兄


干杯。

谢谢您的回复。你能给我一些示例代码吗,因为我是Android新手。你使用这个URL。在哪里传递查询来检索数据?你能给我一些实时示例吗?我将第一次使用它,所以我无法理解它。伙计,我给了你我的现场网站的示例代码。。首先,你要从数据库中检索一个通用列表。然后使用我的web服务。要获得数据库列表作为一个通用的你有很多选择,伙计。。