|
本帖最后由 xuanniao110 于 2016-10-4 17:49 编辑 #include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIComboBox.au3>
#include <GuiConstantsEx.au3>
#include <DateTimeConstants.au3>
#include <EditConstants.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <GuiStatusBar.au3>
#include <ProgressConstants.au3>
#include <Array.au3>
#include <Excel.au3>
#NoTrayIcon
#NoTrayIcon
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#PRE_Outfile_x64=123.exe
#PRE_Res_requestedExecutionLevel=None
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
Global $mdb_data_Server = "172.16.102.40"
Global $mdb_data_id = "wfj"
Global $mdb_data_pwd = "100200"
Global $mdb_data_Company = "Asset"
$zcjl="[资产记录]"
$Number="40009"
$Time="20140930"
$name="IBM服务器"
$Model="8202-E4C"
$Ment="营运部"
$Add="机房服务器柜"
$Num1="1"
$Num2="1"
$Unit="台"
$Status="使用"
$Note="后台服务器"
$addfld = ObjCreate("ADODB.Connection")
$RS = ObjCreate("ADODB.Recordset")
$addfld.Open ("driver={SQL Server};server="&$mdb_data_Server&";uid="&$mdb_data_id&";pwd="&$mdb_data_pwd&";database="&$mdb_data_Company) ;主机名IP127.0.0.1,UID=用户,PWD=密码,database=数据库名
$RS.ActiveConnection = $addfld ; 设定RS 是 conn 的集合 重要的部份
$addfld.Execute("INSERT INTO "&$zcjl&" ([资产编号], [购入时间], [资产名称], [规格型号], [使用部门], [现存地址], [账面数量], [实际数量], [单位], [资产状况], [备注]) VALUES ('"&$Number&"', '"&$Time&"', '"&$name&"', '"&$Model&"', '"&$Ment&"', '"&$Add&"', '"&$Num1&"', '"&$Num2&"', '"&$Unit&"', '"&$Status&"', '"&$Note&"')")
上面代码,可以正常写入,没有任何问题。#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIComboBox.au3>
#include <GuiConstantsEx.au3>
#include <DateTimeConstants.au3>
#include <EditConstants.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <GuiStatusBar.au3>
#include <ProgressConstants.au3>
#include <Array.au3>
#include <Excel.au3>
#NoTrayIcon
Global $mdb_data_Server = "172.16.102.40"
Global $mdb_data_id = "wfj"
Global $mdb_data_pwd = "100200"
Global $mdb_data_Company = "Asset"
;数据表参数
Global $zcjl = "[资产记录]"
Global $DBjl = "[调拨记录]"
$Form3 = GUICreate("资产登记", 407, 316, 567, 316)
$Group5 = GUICtrlCreateGroup("", 3, 0, 401, 281)
$Label9 = GUICtrlCreateLabel("资产编号:", 16, 24, 64, 17)
$Input2 = GUICtrlCreateInput("", 72, 22, 121, 21)
$Label10 = GUICtrlCreateLabel("购入时间:", 205, 23, 64, 17)
$Date3 = GUICtrlCreateDate("", 264, 20, 121, 21)
$Label11 = GUICtrlCreateLabel("资产名称:", 16, 55, 64, 17)
$Input3 = GUICtrlCreateInput("", 72, 53, 121, 21)
$Label12 = GUICtrlCreateLabel("规格型号:", 205, 55, 64, 17)
$Input4 = GUICtrlCreateInput("", 264, 53, 121, 21)
$Label13 = GUICtrlCreateLabel("使用部门:", 16, 86, 64, 17)
$Combo2 = GUICtrlCreateCombo("其他", 72, 84, 121, 21, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "营运部|财务部|超市部|人力部|会员中心")
$Label14 = GUICtrlCreateLabel("现存地址:", 205, 86, 64, 17)
$Input5 = GUICtrlCreateInput("", 264, 84, 121, 21)
$Label15 = GUICtrlCreateLabel("账面数量:", 16, 116, 64, 17)
$Input6 = GUICtrlCreateInput("", 72, 114, 121, 21)
$Label16 = GUICtrlCreateLabel("实际数量:", 205, 116, 64, 17)
$Input7 = GUICtrlCreateInput("", 264, 114, 121, 21)
$Label17 = GUICtrlCreateLabel("资产单位:", 16, 145, 64, 17)
$Input8 = GUICtrlCreateInput("", 72, 143, 121, 21)
$Edit1 = GUICtrlCreateEdit("", 16, 200, 241, 65, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_WANTRETURN))
GUICtrlSetData(-1, "")
$Button8 = GUICtrlCreateButton("登记", 288, 200, 81, 65)
$Label18 = GUICtrlCreateLabel("备注:", 16, 176, 40, 17)
$Label19 = GUICtrlCreateLabel("资产现状:", 205, 145, 64, 17)
$Combo3 = GUICtrlCreateCombo("其他", 264, 143, 121, 21, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "使用|闲置|备用|维修|报废|借出")
$StatusBar3 = _GUICtrlStatusBar_Create($Form3)
Dim $StatusBar3_PartsWidth[2] = [150, -1]
_GUICtrlStatusBar_SetParts($StatusBar3, $StatusBar3_PartsWidth)
_GUICtrlStatusBar_SetText($StatusBar3, @TAB & "乐山王府井购物中心", 0)
_GUICtrlStatusBar_SetText($StatusBar3, @TAB & "营运部资产登记", 1)
_GUICtrlStatusBar_SetMinHeight($StatusBar3, 25)
GUISetState(@SW_SHOW)
Dim $nMsg
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button8
$Number = GUICtrlRead($Input2)
$Time = GUICtrlRead($Date3)
$name = GUICtrlRead($Input3)
$Model = GUICtrlRead($Input4)
$Ment = GUICtrlRead($Combo2)
$Add = GUICtrlRead($Input5)
$Num1 = GUICtrlRead($Input6)
$Num2 = GUICtrlRead($Input7)
$Unit = GUICtrlRead($Input8)
$Status = GUICtrlRead($Combo3)
$Note = GUICtrlRead($Edit1)
If $Number = "" Then
MsgBox(48, "提示", "有项目没有填写!")
ElseIf $name = "" Then
MsgBox(48, "提示", "有项目没有填写!")
Else
If $Num1 = "" Then
MsgBox(48, "提示", "有项目没有填写!")
ElseIf $Model = "" Then
GUICtrlSetData($Input4,"空")
Else
If $Add = "" Then
MsgBox(48, "提示", "有项目没有填写!")
ElseIf $Unit = "" Then
MsgBox(48, "提示", "有项目没有填写!")
Else
If $Num2 = "" Then
MsgBox(48, "提示", "有项目没有填写!")
ElseIf $Ment = "" Then
MsgBox(48, "提示", "有项目没有填写!")
Else
$addfld = ObjCreate("ADODB.Connection")
$RS = ObjCreate("ADODB.Recordset")
$addfld.Open ("driver={SQL Server};server="&$mdb_data_Server&";uid="&$mdb_data_id&";pwd="&$mdb_data_pwd&";database="&$mdb_data_Company) ;主机名IP127.0.0.1,UID=用户,PWD=密码,database=数据库名
$RS.ActiveConnection = $addfld ; 设定RS 是 conn 的集合 重要的部份
$addfld.Execute("INSERT INTO "&$zcjl&" ([资产编号], [购入时间], [资产名称], [规格型号], [使用部门], [现存地址], [账面数量], [实际数量], [单位], [资产状况], [备注]) VALUES ('"&$Number&"', '"&$Time&"', '"&$name&"', '"&$Model&"', '"&$Ment&"', '"&$Add&"', '"&$Num1&"', '"&$Num2&"', '"&$Unit&"', '"&$Status&"', '"&$Note&"')")
$RS.close
$addfld.Close
MsgBox(48, '提示', '资产增加成功!')
EndIf
EndIf
EndIf
EndIf
EndSwitch
WEnd
此代码却怎么都不能写入,无法正常的录入数据
数据表类型设计如图
@kk_lee69 求大神指点 是不是 数据库设计上的问题 |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?加入
×
|