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外部数据库
这种用法仅支持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