Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共2 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:[求助] Insert Into 返回ID

1楼
建筑人生 发表于:2024/4/20 16:17:00

Dim cmd As New SQLCommand
cmd.C
cmd.CommandText = "Insert Into HeTong (gcmc,gcdz,htdw,htbh,xmfzr,htgq,kssj,htxs,htje,fpsl,wcsj,dwmc,dwdz,dwxz,lxr,lxdh1,lxdh2,email,zw,wx,qq,khmc,khzh,khh,swdjh,jlr,jlsj,fj) values ('" & gcmc & "','" & gcdz & "','" & htdw & "','" & htbh & "','" & xmfzr & "','" & htgq & "',#" & kssj & "#,'" & htxs & "'," & htje & "," & fpsl & ",#" & wcsj & "#,'" & dwmc & "','" & dwdz & "','" & dwxz & "','" & lxr & "','" & lxdh1 & "','" & lxdh2 & "','" & email & "','" & zw & "','" & wx & "','" & qq & "','" & khmc & "','" & khzh & "','" & khh & "','" & swdjh & "','" & jlr & "',#" & jlsj & "#,'" & fj & "');Select SCOPE_IDENTITY()"



Dim id As Integer = cmd.ExecuteScalar()'新增行ID

MessageBox.Show(ID)


加了黄色位置,提示在 SQL 语句结尾之后找到字符。,是Access外部数据库
2楼
有点蓝 发表于:2024/4/20 16:23:00
这种用法仅支持SqlServer

access只能是插入后,再另外使用能够唯一识别的列查询需要的行的主键。比如有一个编号列,每一行编号都不一样,可以

Dim cmd As New SQLCommand
cmd.C
cmd.CommandText = "Insert Into HeTong (g......
cmd.ExecuteNonQuery()
cmd.CommandText = " select [_Identify] from HeTong where 某编号编号='xxxx'"
Dim id As Integer = cmd.ExecuteScalar()'新增行ID


共2 条记录, 每页显示 10 条, 页签: [1]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .02344 s, 2 queries.