我有两个名为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>
由于
答案 0 :(得分:0)
虽然这可能有点晚了,但我刚看到你的问题,你的插入语句显示5个值而且只有一个字段,你的值应该是'apple,grape,orange ......'
从本质上讲,你正在尝试将5个不同的数据列放入一列,而sql不能像那样工作。
我使用sql存储过程并通过冷融合调用它们,这样我就不会得到任何潜在的sql注入问题。
您没有任何参数,并且通过URL使用字符串会为sql注入攻击敞开大门。
希望这有帮助。
吉姆