Copy Code code as follows:
public class Returnresult
{
public int Curindex {get; set;}
Public DataTable idxlist {get; set;}
}
Test database connection
[WebMethod (Description = "!!! Test database connection, link string in Web.config ")]
public bool Conectdb ()
{
Strcon = configurationsettings.appsettings["Sqlconduke"];
conn = new SqlConnection (Strcon);
Try
{
Conn. Open ();
return true;
}
catch (Exception)
{
return false;
}
Finally
{
Conn. Close ();
}
}
Copy Code code as follows:
[WebMethod (Description = "Get detailed data (DataTable) based on <b> photo name </b> Strtb,eg:panview;strimgname,eg : 20131019072740-0000150 ")]
Public DataTable Getinfobyimgname (string strtb, String strimgname)
{
BOOL Ifcon = Conectdb ();
if (Ifcon)
{
String Sql_bfcar = "SELECT * FROM dbo." + STRTB + "where imagename like '%" + strimgname + "%";
da = new SqlDataAdapter (SQL_BFCAR, Conn);
myDS = new DataSet ();
Da. Fill (myds);
Return myds. Tables[0];
}
Else
{
return null;
}
}
[WebMethod = Description to get all the data (returnresult) of the link based on <b> photo name </b> Strtb,eg:panview;strimgname,eg : 20131019072740-0000150 ")]
Public Returnresult Getlinkdtbyimgname (string strtb, String strimgname)
{
Returnresult Returnresult = new Returnresult ();
BOOL Ifcon = Conectdb ();
if (Ifcon)
{
Returnresult.curindex = Convert.ToInt32 (Getinfobyimgname (STRTB, Strimgname). Rows[0][0]);
String strlinkguid = Getinfobyimgname (STRTB, Strimgname). ROWS[0][1]. ToString ();
String Sql_bfcar = "SELECT * FROM dbo." + STRTB + "where linkguid like '%" + strlinkguid + "%";
da = new SqlDataAdapter (SQL_BFCAR, Conn);
myDS = new DataSet ();
Da. Fill (myds);
Returnresult.idxlist = myDS. Tables[0];
return returnresult;
}
Else
{
return null;
}
}
Flex Code:
Copy Code code as follows:
<?xml version= "1.0" encoding= "Utf-8"?>
<s:application xmlns:fx= "http://ns.adobe.com/mxml/2009"
Xmlns:s= "Library://ns.adobe.com/flex/spark"
xmlns:mx= "Library://ns.adobe.com/flex/mx" minwidth= "955" minheight= "creationcomplete=" application1_ Creationcompletehandler (event) ">
<fx:Script>
<! [cdata[
Import mx.collections.ArrayCollection;
Import Mx.controls.Alert;
Import mx.events.FlexEvent;
Import mx.rpc.events.FaultEvent;
Import mx.rpc.events.ResultEvent;
public var arr:arraycollection=new arraycollection ();
public var aaa:string=new String ();
protected function Webservice1_faulthandler (event:faultevent): void
{
Alert.show (Event.fault.toString ());
}
protected function Getlinkdtbyimgnamehandler (event:resultevent): void
{
Aaa=this.myweb.getlinkdtbyimgname.lastresult.curindex;
Arr=this.myweb.getlinkdtbyimgname.lastresult.idxlist.tables.table.rows;
Aaa=event.result.curindex;
Arr=event.result.idxlist.tables.table.rows;
Alert.show (aaa+ "" +arr.length.tostring ());
}
protected function Application1_creationcompletehandler (event:flexevent): void
{
Myweb.getlinkdtbyimgname ("Panview", "20131019072740-0000150");
}
]]>
</fx:Script>
<fx:Declarations>
<!--place non-visual elements (such as services, value objects) here-->
<s:webservice id= "MyWeb" wsdl= "Http://10.19.1.55/serverPano/WebServiceDuke.asmx?" WSDL "fault=" Webservice1_faulthandler (event) >
<s:operation name= "Getlinkdtbyimgname" result= "Getlinkdtbyimgnamehandler (event)" ></s:operation>
</s:WebService>
</fx:Declarations>
</s:Application>