qq_27895609 2018-11-10 17:22 采纳率: 50%
浏览 409
已结题

数据库已连接并打开,但无法将文本框内容保存至数据表内,只用as3.0或Flex,求解决。

<?xml version="1.0" encoding="utf-8"?>
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" width="1400" height="900" backgroundFrameRate="60" title="单词记忆游戏机" backgroundColor="#FFFFFF">
fx:Script
<![CDATA[
import mx.controls.Alert;
import mx.utils.UIDUtil;
protected function SaveButton1_clickHandler(event:MouseEvent):void
{
var conn:SQLConnection = new SQLConnection()
var folder:File = File.applicationDirectory;
var dbFile:File = folder.resolvePath("DaTa/nWord.db");

            try
            {
                conn.open(dbFile);
                trace("shujuchenggong"+dbFile.nativePath);

            }
            catch (error:SQLError)
            {
                trace("xingxi",error.message);
                trace("xiangqing",error.details);

            }
            var insertDt:SQLStatement=new SQLStatement();
            var insertSQL:String="insert into ziMuShunXu(id,name,chinese1,chinese2,chinese3,chinese4," +
                "chinese5,chinese6,chinese7,chinese8,chinese9,chinese10) values(:id,:name,:chinese1,:chinese2," +
                ":chinese3,:chinese4,:chinese5,:chinese6,:chinese7,:chinese8,:chinese9,:chinese10)";
            var idstr:String = UIDUtil.createUID();
            var namestr:String = ENname.text;
            var chinesestr1:String = CNname1.text;
            var chinesestr2:String = CNname2.text;
            var chinesestr3:String = CNname3.text;
            var chinesestr4:String = CNname4.text;
            var chinesestr5:String = CNname5.text;
            var chinesestr6:String = CNname6.text;
            var chinesestr7:String = CNname7.text;
            var chinesestr8:String = CNname8.text;
            var chinesestr9:String = CNname9.text;
            var chinesestr10:String = CNname10.text;
            insertDt.sqlConnection = conn;
            insertDt.text = insertSQL;
            insertDt.parameters[":id"]=idstr;
            insertDt.parameters[":name"]=namestr;
            insertDt.parameters[":chinese1"]=chinesestr1;
            insertDt.parameters[":chinese2"]=chinesestr2;
            insertDt.parameters[":chinese3"]=chinesestr3;
            insertDt.parameters[":chinese4"]=chinesestr4;
            insertDt.parameters[":chinese5"]=chinesestr5;
            insertDt.parameters[":chinese6"]=chinesestr6;
            insertDt.parameters[":chinese7"]=chinesestr7;
            insertDt.parameters[":chinese8"]=chinesestr8;
            insertDt.parameters[":chinese9"]=chinesestr9;
            insertDt.parameters[":chinese10"]=chinesestr10;
            insertDt.execute();
            Alert.show("已保存"+namestr+"及汉语意思","提示");
        }
    ]]>
</fx:Script>
<s:Label x="400" y="10" text="工作与爱好统一是最幸福的" color="#00000" fontSize="50" fontFamily="叶根友毛笔行书2.0版"/>
<s:Panel title="输入框" x="5" y="90" width="300" height="650" id="ShuRu">
    <s:Label x="20" y="10" text="请输入单词:" color="#00000" fontSize="20" fontFamily="宋体"/>
    <s:TextInput restrict="A-Z,a-z" x="148" y="10" id="ENname"/>
    <s:Label x="20" y="45" text="请输入汉意1:" color="#00000" fontSize="20" fontFamily="宋体"/>
    <s:TextInput restrict="a-z\.\,\{'[\u4e00-\u9fa5]'}" x="148" y="45" id="CNname1"/>
    <s:Label x="20" y="80" text="请输入汉意2:" color="#00000" fontSize="20" fontFamily="宋体"/>
    <s:TextInput x="148" y="80" id="CNname2"/>
    <s:Label x="20" y="115" text="请输入汉意3:" color="#00000" fontSize="20" fontFamily="宋体"/>
    <s:TextInput x="148" y="115" id="CNname3"/>
    <s:Label x="20" y="150" text="请输入汉意4:" color="#00000" fontSize="20" fontFamily="宋体"/>
    <s:TextInput x="148" y="150" id="CNname4"/>
    <s:Label x="20" y="185" text="请输入汉意5:" color="#00000" fontSize="20" fontFamily="宋体"/>
    <s:TextInput x="148" y="185" id="CNname5"/>
    <s:Label x="20" y="220" text="请输入汉意6:" color="#00000" fontSize="20" fontFamily="宋体"/>
    <s:TextInput x="148" y="220" id="CNname6"/>
    <s:Label x="20" y="255" text="请输入汉意7:" color="#00000" fontSize="20" fontFamily="宋体"/>
    <s:TextInput x="148" y="255" id="CNname7"/>
    <s:Label x="20" y="290" text="请输入汉意8:" color="#00000" fontSize="20" fontFamily="宋体"/>
    <s:TextInput x="148" y="290" id="CNname8"/>
    <s:Label x="20" y="325" text="请输入汉意9:" color="#00000" fontSize="20" fontFamily="宋体"/>
    <s:TextInput x="148" y="325" id="CNname9"/>
    <s:Label x="20" y="360" text="请输入汉意10:" color="#00000" fontSize="20" fontFamily="宋体"/>
    <s:TextInput x="148" y="360" id="CNname10"/>
    <s:Button x="200" y="550" label="保存" color="#fd0000" fontSize="15" width="50" height="30" click="SaveButton1_clickHandler(event)"/>
</s:Panel>
<s:Panel title="单词列表" x="320" y="90" width="1075" height="650" id="XianShi">
</s:Panel>
<fx:Declarations>
    <!-- 将非可视元素(例如服务、值对象)放在此处 -->
</fx:Declarations>

/s:WindowedApplication

  • 写回答

1条回答

  • devmiao 2018-11-11 05:50
    关注
    评论

报告相同问题?

悬赏问题

  • ¥20 求数据集和代码#有偿答复
  • ¥15 关于下拉菜单选项关联的问题
  • ¥20 java-OJ-健康体检
  • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
  • ¥15 使用phpstudy在云服务器上搭建个人网站
  • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
  • ¥15 vue3+express部署到nginx
  • ¥20 搭建pt1000三线制高精度测温电路
  • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况
  • ¥15 画两个图 python或R