我有两个名为 Test 和 Save_Test 的表。Test 表有一列有五个值,而 Save_Test 表有一列没有值。我需要创建保存按钮,这样当我从 Test 表中选择一个值并单击时在保存按钮上,它应该存储在 Save_Test 表中。每次单击保存按钮时,以前存储在 save_Test 表中的值都应该替换为新选择的 Test 表值。这是我的代码。请帮忙。
<?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="600" initialize="application1_initializeHandler(event)">
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.collections.ArrayList;
import mx.events.FlexEvent;
import mx.events.ValidationResultEvent;
import mx.rpc.AsyncResponder;
import mx.rpc.AsyncToken;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.rpc.soap.WebService;
private var web:WebService;
private var list:ArrayList = new ArrayList();
protected function application1_initializeHandler(event:FlexEvent):void
{
web = new WebService();
web.wsdl = "https://www.geoviewer8.com/gv8webservices/CSF_NewGVOConfig/GVOConfig.asmx?wsdl";
web.loadWSDL();
var s:String = "SELECT * FROM [CSFTestNew].[dbo].[Test]";
var t:AsyncToken = web.GetRec("[Test]", s, "1", "SQLExpress");
t.addResponder(new AsyncResponder(onResult, onFault, t));
}
protected function onResult(event:ResultEvent, token:Object=null):void
{
if(event.result.GetRecResult.Tables != null)
{
for each(var table:Object in event.result.GetRecResult.Tables)
{
for each(var row:Object in table.Rows)
{
list.addItem(row);
}
}
}
}
protected function onFault(event:FaultEvent, token:Object=null):void
{
trace(event.fault.toString());
}
private function validate(event):void
{
var p:String = "INSERT INTO [CSFTestNew].[dbo].[Save_Test]([Areas]) VALUES ('Apple','Banana','Mango','Grapes','StrawBerry')";
/* var event:ValidationResultEvent = validate(); */
}
protected function btn_click(event:MouseEvent):void
{
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:ComboBox id="cbareas" x="201" y="241" dataProvider="{list}" labelField="Areas"
requireSelection="true" />
<s:Button id="btn" x="417" y="243" label="Save" click="btn_click(event)" />
</s:Application>
谢谢