谁对数据库熟悉?帮我看看这个语句哪错吧~~谢谢
测倒数第二行的句子。。。调试半天了,也不对。目的:如果IDs列的数据已存在就放弃操作,不存在就写入数据
If Not FileExists(@ScriptDir & "\mdb") Then DirCreate (@ScriptDir & "\mdb")
$mdb_data_path = @ScriptDir & "\mdb\" & @MON & @MDAY & ".mdb"
$mdb_data_pwd = "passMDB"
FileDelete($mdb_data_path)
$newMdb = ObjCreate("ADOX.Catalog")
$newMdb.Create("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $mdb_data_path)
$newMdb.ActiveConnection.Close;建数据库
$addtbl = ObjCreate("ADODB.Connection")
$addtbl.open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $mdb_data_path)
$addtbl.Execute("CREATE TABLE tywb")
$addtbl.Close;建表
$addfld = ObjCreate("ADODB.Connection")
$addfld.open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $mdb_data_path)
$addfld.Execute("ALTER TABLE tywb ADD xu identity(1, 1) primary key,IDs int,lei char,yin char,jin char")
$addfld.Close;建列表名
$addfld = ObjCreate("ADODB.Connection")
$addfld.open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & $mdb_data_path & ";Jet Oledb:Database Password=" & $mdb_data_pwd)
$sQuery ="insert into tywb (IDs,lei,yin,jin) values('123','还账','农行','200000')"
$addfld.Execute($sQuery)
$addfld.close
$addfld = ObjCreate("ADODB.Connection")
$addfld.open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & $mdb_data_path & ";Jet Oledb:Database Password=" & $mdb_data_pwd)
$addfld.Execute("insert into tywb (IDs,lei,yin,jin) values('123','ss','ss','ss') where ('123') not in (IDs)")
$addfld.close
[ 本帖最后由 maker 于 2008-11-29 15:34 编辑 ] 27行
Insert语句不支持where 请问楼上,是au3不支持吗?群里有个熟悉的说语句没问题,有什么解决的好办法吗?
[ 本帖最后由 maker 于 2008-11-28 19:57 编辑 ] ADO不支持
Insert语句不支持使用where。
使用游标写入记录,是最好的办法了。 嗯。。。游标是目前为止最好的解决办法。 If Not FileExists(@ScriptDir & "\mdb") Then DirCreate(@ScriptDir & "\mdb")
$mdb_data_path = @ScriptDir & "\mdb\" & @MON & @MDAY & ".mdb"
$mdb_data_pwd = "passMDB"
FileDelete($mdb_data_path)
$newMdb = ObjCreate("ADOX.Catalog")
$newMdb.Create("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $mdb_data_path)
$newMdb.ActiveConnection.Close;建数据库
$addtbl = ObjCreate("ADODB.Connection")
$addtbl.open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $mdb_data_path)
$addtbl.Execute("CREATE TABLE tywb")
$addtbl.Close;建表
$addfld = ObjCreate("ADODB.Connection")
$addfld.open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $mdb_data_path)
$addfld.Execute("ALTER TABLE tywb ADD xu identity(1, 1) primary key,IDs int,lei char,yin char,jin char")
$addfld.Close;建列表名
$addfld = ObjCreate("ADODB.Connection")
$addfld.open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & $mdb_data_path & ";Jet Oledb:Database Password=" & $mdb_data_pwd)
$sQuery = "insert into tywb (IDs,lei,yin,jin) values('123','还账','农行','200000')"
$addfld.Execute($sQuery)
$addfld.close
$addfld = ObjCreate("ADODB.Connection")
$RS = ObjCreate("ADODB.Recordset")
$addfld.open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & $mdb_data_path & ";Jet Oledb:Database Password=" & $mdb_data_pwd)
$RS.ActiveConnection=$addfld
$rs.open('select * from tywb where IDS=234')
If Not $rs.eof Then
MsgBox(0, 0, "已存在插入的列")
Else
$addfld.Execute("insert into tywb (IDs,lei,yin,jin) values('234','ss','ss','ss')")
EndIf
$addfld.close 恩,谢谢各位~ 游标还没接触过,改天找找资料看看 这种情况就是需要先判断才好,你原来的语法都不对
其实你要先在Access或sql中,把你的语句执行一下,看能执行不
页:
[1]