找回密码
 加入
搜索
查看: 1804|回复: 5

这段代码错哪了?

[复制链接]
发表于 2009-2-15 21:16:39 | 显示全部楼层 |阅读模式
本帖最后由 小凯 于 2010-5-21 17:49 编辑

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$mdb_data_path="good.mdb"
$mdb_data_pwd="1121"
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("输入数据", 153, 159, 351, 179)
$name = GUICtrlCreateInput("名字", 8, 16, 121, 21)
$tel = GUICtrlCreateInput("电话", 8, 40, 121, 21)
$qq = GUICtrlCreateInput("QQ", 8, 64, 121, 21)
$e_mail = GUICtrlCreateInput("e_mail", 8, 88, 121, 21)
$Button1 = GUICtrlCreateButton("写入", 80, 112, 49, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        sx()
        EndSwitch
WEnd

Func sx()
         $addfld = ObjCreate("ADODB.Connection")
      
       $addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & $mdb_data_path & ";Jet Oledb:Database telword=" & $mdb_data_pwd)
      $x=0
       While 1
        $x+=1
       if $x >1 Then ExitLoop
      $addfld.Execute("insert into tywb (name,tel,qq,e_mail) values('"&$name&"','"&$tel&"','"&$qq&"','"&$e_mail&"')")
     WEnd
      ; $conn.Execute("insert into tywb (name,tel,qq,e_mail) values('"&$name&"','"&$tel&"','"&$qq&"','"&$e_mail&"')")
     ;  $RS.close
          $addfld.close
         MsgBox(4096, "提示:"," 成功写入!")  
EndFunc

[ 本帖最后由 小凯 于 2009-2-16 10:27 编辑 ]
发表于 2009-2-15 21:34:52 | 显示全部楼层
谁有时间一个个去查啊 说明白出现什么错误了 发个图

怎么提问的都不自己想想呢

以为知识都是伸手要来的吗?
发表于 2009-2-15 22:02:04 | 显示全部楼层
你有数据库文件吗
 楼主| 发表于 2009-2-16 10:26:19 | 显示全部楼层
晕!不好意思!
这段代码能运行!
但就是不能写入数据库  数据库有!
发表于 2009-2-16 11:05:59 | 显示全部楼层
这纯粹是楼主没看帮助文档就来了
获取文本框的内容不是你这么写的 好好翻翻帮助吧
我很同意2楼的说法
发表于 2009-2-17 21:42:36 | 显示全部楼层
什么数据库?SQL还是Access?

你的代码里面没有包含SQL的错误信息么?

这个是我用的,你自己加进去

Func ODBCJET_ErroHandler()
        Local $err_msg
        $err_msg = "SQL Error - " & $Err.Number & @TAB & "SOURCE: " & $Err.Source & @TAB & "DESC: " & $Err.Description
        _FileWriteLog(@ScriptDir & "\Error.log", $err_msg)
        Local $err1 = $Err.number
    If $err1 = 0 Then $err1 = -1
        SetError($Err)
EndFunc ; ==> ODBCJET_ErroHandler()
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-23 07:30 , Processed in 0.076487 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表