如何插入和获取.NET Web服务数据对象,以我的Andr​​oid应用程序 [英] How to insert and get .NET web-service data Object to My Android App

查看:223
本文介绍了如何插入和获取.NET Web服务数据对象,以我的Andr​​oid应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Web服务的.NET它插入并从数据库对象的检索数据的..
我会在这里复制Web服务的某些部分。

I have a web-service in .NET it's inserting and retrieving data's from database as object's.. I'll copy some part of web-service here..

   [WebMethod(Description = "This is used to insert details into sql server")]

    public string InsertDetails(DataTable myDetails, string STR1)
    {
        try
        {
            foreach (DataRow row in myDetails.Rows)
            {
                SqlCommand cmd = new SqlCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "dbo.InsertQry";
                cmd.Parameters.Add(new SqlParameter("@P_no", row["POD_Number"].ToString()));
                cmd.Parameters.Add(new SqlParameter("@P_id", STR1));
                cmd.Parameters.Add(new SqlParameter("@P_author", Convert.ToInt64(row["P_author"])));

                //opening the connection
                cmd.Connection = sqlCon;
                sqlCon.Open();
                int retValue = cmd.ExecuteNonQuery();
                sqlCon.Close();
                if (retValue == 0)
                    return "false";
            }
            return "true";
        }

        catch (Exception ex)
        {
            ErrorLogger(ex);
            return "false";
        }
    }

// --------------------------------------------- --------------------------------------结果
       [的WebMethod(说明=这是用来从SQL Server的详细信息)]

//-----------------------------------------------------------------------------------
[WebMethod(Description = "This is used to get details from sql server")]

    public DataSet GetDetails(string STR1)
    {
        DataSet ds = new DataSet();
        try
        {
            SqlCommand cmd = new SqlCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "dbo.SelectQryFromDB";
            //opening the connection
            cmd.Connection = sqlCon;
            sqlCon.Open();
            ds.DataSetName = "myTbl";
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            da.Fill(ds,"myTbl");
            sqlCon.Close();
            return ds;
        }

        catch (Exception ex)
        {
            ErrorLogger(ex);
            ds.DataSetName = "Error";
            return ds;
        }
    }

// ----------------------------

//----------------------------

任何一所给我提供的细节帮助我,我怎么能发送这些数据的和检索数据在Android..This是我第一次应用程序,我不知道多少??
请提供详细资料我,这样我可以插入和使用Web服务??获取数据的

Any-one Help me by providing me the details how can i send those data's and retrieve data's in Android..This is my first application so i don't know much?? Please Provide me details so that i can insert and get data's using web-service??

我听说kSOAP2的,我尝试使用kSOAP2 ..

I heard of kSOAP2 and i'm trying to accomplish this by using kSOAP2..

推荐答案

KSOAP 工作是具有挑战性的,有时。首先,您需要确保你的web服务工作正常,并且给你正确的结果。

Working in Ksoap can be challenging sometimes. You first need to make sure your webservice is working fine and is giving you the proper result.

如果这样做了,那么你可以从Android的使用 KSOAP 库中的相同。

If that's done then you can consume the same from Android using ksoap library.

下面是几个环节,这将有助于解决您的问题:

Here are few links that will help solve your problem:

1)<一href=\"http://stackoverflow.com/questions/7860887/how-to-call-a-local-web-service-from-an-android-mobile-application\">How调用来自Android的移动应用程序的本地Web服务将帮助您了解您需要如何做一个 KSOAP 电话。

1) How to call a local web service from Android mobile application will help you understand how you need to make a Ksoap call.

2)<一href=\"http://stackoverflow.com/questions/8075626/pass-an-array-to-a-soap-web-service-for-inserting-into-remote-database\">Inserting通过KSOAP

3)<一个href=\"http://stackoverflow.com/questions/8213654/json-string-returned-from-soap-web-service-containing-no-records-for-table\">Returning从服务器到Android 数据

这篇关于如何插入和获取.NET Web服务数据对象,以我的Andr​​oid应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆