小凯 发表于 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 编辑 ]

xrbenbeba 发表于 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楼的说法

xinlu8439 发表于 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()
页: [1]
查看完整版本: 这段代码错哪了?