例子:
with adoqu1,sql do
begin
close;clear;
add('insert into operatorcode,name,password)')
add('values(:code,:name,:password)'
Parameters.ParamByName('code').Value:=trim(e_code.Text);
Parameters.ParamByName('name').Value:=trim(E_name.Text);
Parameters.ParamByName('password').Value:=trim(E_password.Text);
try
execsql;
ModalResult := mrok;
except
showmessage('保存错误');
end;
如果数据用 access2000有错误,用sqlserver2000不出错!
可是如果去掉增加password 则正常,并且在access的查询中用 insert into 也不出错
这是为什么?????????????????谢谢!!!
解决后立即给分!!!!
with adoqu1,sql do
begin
close;clear;
add('insert into operatorcode,name,password)')
add('values(:code,:name,:password)'
Parameters.ParamByName('code').Value:=trim(e_code.Text);
Parameters.ParamByName('name').Value:=trim(E_name.Text);
Parameters.ParamByName('password').Value:=trim(E_password.Text);
try
execsql;
ModalResult := mrok;
except
showmessage('保存错误');
end;
如果数据用 access2000有错误,用sqlserver2000不出错!
可是如果去掉增加password 则正常,并且在access的查询中用 insert into 也不出错
这是为什么?????????????????谢谢!!!
解决后立即给分!!!!
解决方案 »
- 简单问题,关于Excel
- 用代码创建VPN连接的问题,VB的已经搞定,Delphi的咋就搞不定了,大虾们帮我看看(附VB和delphi的代码)
- 请问哪里有TSeSkinPanel、TSeSkinLabel....等TSeSkin系列的控件下载????
- delphi 中怎么样做链接的测试,要把页面取到客户端,但是不需要显示,只判断有没有页面就行了,谢谢
- 为什么ClientSocket.ClientSocket1Read有时激发不了?急等
- WIN消息的区分
- 希望各位DELPHI高手公开你们的QQ ,MSN MESSAGER ,以便充分发挥广大程序员的智慧,大家取长补短,使各自的技术更上一层楼! (非高手谢
- 怎样操作EXCEL表?!急!!!!!!!!!!!!
- 本人想退出delphi版,大家进来送个行吧?
- 想把DAT文件写到Memo里,但是读取数组数据类型与string转换不会,请教大佬
- 我用Delphi编写的Dll用Regsvr32注册为何报错
- 当我在SaveDialog 中点取消时,却不能关闭“另存为“的窗体,我要怎么做才能关掉它
with adoqu1,sql do,两个?出现什么错了?不要处理,看看系统出什么错了呀
用
add('insert into operator(code,name,"password")')//你还少写了一个(
adoqu1是TADOQuery控件,SQL是什么??改成这样试试:
with adoqu1 do
begin
close;clear;
SQL.add('insert into operatorcode,name,password)')
SQL.add('values(:code,:name,:password)'
Parameters.ParamByName('code').Value:=trim(e_code.Text);
Parameters.ParamByName('name').Value:=trim(E_name.Text);
Parameters.ParamByName('password').Value:=trim(E_password.Text);
try
execsql;
ModalResult := mrok;
except
showmessage('保存错误');
end;
如果不行,就把错误信息贴出来
Access很少用, 我也认为有可能是关键字冲突最好不不取这样的名字什么Name啊, Password啊,
改一下, FName, pwd之类的, 包起来试试 [Name], [Password]
Dim fact, pact As String
Dim xbackcolor As Long
Dim xcount As Integer
Dim pra_rst, pra_rst1, pra_rst2 As ADODB.Recordset
Set pra_rst = New ADODB.Recordset
Set pra_rst1 = New ADODB.Recordset
Set pra_rst2 = New ADODB.Recordset
On Error GoTo errorinfo
If Prearrange = False Then
If Me![date_enterdate] > Now Then
MsgBox "The Time Must be littler or equal than The system!"
Exit Sub
End If
Else
If Me![date_enterdate] < Now Then
MsgBox "The Time Must be later than The system!"
Exit Sub
End If
End If
If IsNull(Me![cbo_goodtype]) Then
MsgBox "please check the 壿暔庬椶"
Exit Sub
End If
If Saved = True Then
MsgBox "The Information is Already Saved!"
Exit Sub
End If
If pra_rst2.State = 1 Then
pra_rst2.Close
End If
pra_rst2.Open "select a.*,b.chr_WarehouseID from #mid_COEnterdetail a left join AST_CoEnterInfo b on b.chr_PactID=a.chr_PactID and " & _
"b.chr_CnFactoryID=a.chr_CnFactoryID and b.chr_EnterBillID=a.chr_EnterBillID where a.int_CtnNum>0 or a.int_PcsNum>0", CurrentProject.Connection, adOpenDynamic, adLockBatchOptimistic, adCmdText
If pra_rst2.RecordCount = 0 Then
MsgBox "There Are No Products In This EnterStore!"
Exit Sub
End If
If mod_ast.lslmessagebox(1) = vbNo Then
Saved = False
add = False
Exit Sub
End If
'mod_ast.init_rst
With CurrentProject.Connection
.BeginTrans
mod_ast.init_rst
If pra_rst.State = 1 Then
pra_rst.Close
End If
pra_rst2.MoveFirst
xcount = 0 '昗婰弞娐師澤
xbackcolor = 0 ' 16777215
Do Until pra_rst2.EOF
mod_ast.Rusoult_CoBillNo pra_rst2!chr_PactID, "I"
If fact = pra_rst2!chr_CnFactoryID And pact = pra_rst2!chr_PactID Then ' 敾澬惀斲啜廳暅宊栺
GoTo out1
End If
fact = pra_rst2!chr_CnFactoryID
pact = pra_rst2!chr_PactID
If pra_rst.State = 1 Then
pra_rst.Close
End If
pra_rst.Open "select chr_PactID,chr_EnterBillID,vchr_EnterSignID,chr_JpClientID,chr_CnClientID,chr_CnFactoryID,vchr_Warehouse,bool_Prearrange,bool_TaskProduct from #coenterinfo where chr_pactid='" & pra_rst2!chr_PactID & "' and " & _
"chr_CnFactoryID='" & pra_rst2!chr_CnFactoryID & "' order by chr_PactID", CurrentProject.Connection, adOpenDynamic, adLockBatchOptimistic, adCmdText
' pra_rst.MoveFirst
' Do Until pra_rst.EOF
If nindex = 1 Then
If IsNull(pra_rst!vchr_Warehouse) Then
MsgBox "Any Warehouses Have Not Been Input! Please Input It"
Saved = False
add = False
.RollbackTrans
Exit Sub
End If
Else
pra_rst!vchr_Warehouse = "梊栺"
End If
pra_rst1.Open "insert into ast_coenterinfo (chr_pactid,chr_EnterBillID,vchr_EnterSignID,sdt_StartDate," & _
"chr_JpClientID,chr_CnClientID,chr_CnFactoryID,chr_OperaterID,chr_WarehouseID,bool_Prearrange,bool_TaskProduct)" & _
"values('" & pra_rst!chr_PactID & "','" & mod_ast.pub_str2 & "','" & pra_rst!vchr_EnterSignID & "','" & Me![date_enterdate] & "','" & _
pra_rst!chr_JpClientID & " ','" & pra_rst!chr_CnClientID & "','" & pra_rst!chr_CnFactoryID & "','','" & IIf(nindex = 1, mod_ast.warehouse_id(pra_rst!vchr_Warehouse), "梊栺") & "','" & IIf(Prearrange, 1, 0) & "','" & IIf(TaskProduct, 1, 0) & "')", CurrentProject.Connection, adOpenDynamic, adLockBatchOptimistic, adCmdText
mod_ast.init_rst
mod_ast.rst.Open "update #coenterinfo set chr_enterbillid='" & mod_ast.pub_str2 & "' where chr_pactid='" & pra_rst!chr_PactID & "' and chr_cnfactoryid='" & pra_rst!chr_CnFactoryID & "'", CurrentProject.Connection, adOpenDynamic, adLockBatchOptimistic, adCmdText
mod_ast.init_rst
mod_ast.rst.Open "update #mid_coenterdetail set chr_enterbillid='" & mod_ast.pub_str2 & "' where chr_pactid='" & pra_rst!chr_PactID & "' and (int_CtnNum>0 or int_PcsNum>0)", CurrentProject.Connection, adOpenDynamic, adLockBatchOptimistic, adCmdText
xcount = xcount + 1
' Select Case xcount
' Case 1:
' xbackcolor = 0 '麷
' Case 2:
' xbackcolor = 255 '峠
' Case 3:
' xbackcolor = 65535 'yellow
' Case 4:
' xbackcolor = 16711680 '棔
' Case 5:
' xbackcolor = 4194432 '妼
' Case 6:
' xbackcolor = 12615680 '扺棔
' Case 7:
' xbackcolor = 16711808 '巼
' Case 8:
' xbackcolor = 16711935 '戝峠
' Case 9:
' xbackcolor = 8421504 '奃
' Case 10:
' xbackcolor = 32768 '怺麔
'Case Else
' xbackcolor = 12615808 '扺巼
'End Select
out1:
' Form_sub_PactInCoEnter![edt_PactName].ForeColor = xbackcolor
' Form_SUB_ASTD002_PRODUCTLIST![Text49].ForeColor = xbackclolr
sql = "insert into AST_CoEnterDetail(chr_PactID,chr_EnterBillID,vchr_EnterID,chr_CnFactoryID," & _
"vchr_ProductName,vchr_EnterProduct,vchr_Color,vchr_Size,vchr_Unit,int_CtnNum,int_PcsNum,chr_BoxUnit," & _
"chr_PieceUnit,int_Distory,int_Water,chr_DistoryUnit,chr_WaterUnit,mem_memo)" & _
"values('" & pra_rst2!chr_PactID & "','" & mod_ast.pub_str2 & "','" & pra_rst2!vchr_EnterID & "','" & pra_rst2!chr_CnFactoryID & "','" & pra_rst2!vchr_ProductName & "','" & _
pra_rst2!vchr_EnterProduct & "','" & pra_rst2!vchr_Color & "','" & pra_rst2!vchr_Size & "','" & pra_rst2!vchr_Unit & "','" & pra_rst2!int_CtnNum & "','" & pra_rst2!int_PcsNum & "','" & pra_rst2!chr_BoxUnit & "','" & pra_rst2!chr_PieceUnit & "','" & _
pra_rst2!int_Distory & "','" & pra_rst2!int_Water & "','" & pra_rst2!chr_DistoryUnit & "','" & pra_rst2!chr_WaterUnit & "','" & pra_rst2!mem_Memo & "')"
mod_ast.init_rst
mod_ast.rst.Open sql, CurrentProject.Connection, adOpenDynamic, adLockBatchOptimistic, adCmdText
mod_ast.init_rst
If Prearrange = False Then
sql = "insert into AST_StockDetail(chr_PactID, ldt_DateTime, chr_Billtype, vchr_BillTypeID," & _
"vchr_WarehouseDepID, vchr_CnFactoryID, vchr_InProduct, vchr_Color, vchr_Size, vchr_Unit, chr_CargoGrade, int_CtnNum, int_PcsNum,chr_PieceUnit) " & _
"values('" & pra_rst2!chr_PactID & "','" & Me![date_enterdate] & "','COI','" & pra_rst2!chr_EnterBillID & "','" & _
pra_rst2!chr_WarehouseID & "','" & pra_rst2!chr_CnFactoryID & "','" & pra_rst2!vchr_EnterProduct & "','" & pra_rst2!vchr_Color & "','" & _
pra_rst2!vchr_Size & "','" & pra_rst2!vchr_Unit & "','枹嶌嬈昳','" & pra_rst2!int_CtnNum & "','" & pra_rst2!int_PcsNum & "','" & pra_rst2!chr_PieceUnit & "')"
mod_ast.rst.Open sql, CurrentProject.Connection, adOpenDynamic, adLockBatchOptimistic, adCmdText
mod_ast.init_rst
mod_ast.rst.Open "update AST_PactInfo set vchr_PactState='幏峴拞' where chr_pactid='" & pra_rst2!chr_PactID & "'", CurrentProject.Connection, adOpenDynamic, adLockBatchOptimistic, adCmdText
End If
pra_rst2.MoveNext
Loop
Form_SUB_ASTD002_PACTLIST.RecordSource = "#coenterinfo"
Form_SUB_ASTD002_ProductList.RecordSource = "#mid_COEnterdetail"
.CommitTrans
End With
add = True
Saved = True
Exit Sub
errorinfo:
MsgBox Err.DescriptionEnd Sub
里面有很多INSERT INTO 呵呵
改掉关键字立即就好!,可见sqlserver2000的关键字和access的不一样!
但那个with adoqu1,sql do算什么写法啊
我第一次见到