469,126 Members | 1,271 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,126 developers. It's quick & easy.

Problem In Vb

Hi

I A Working On Vb As Front End And Sqlplus As Back End. I Want That Wehn I Enter A New Record In A Database Through Vb, The Form Number Field Automatically Increments Itself By 1.
Feb 24 '07 #1
1 864
vijaydiwakar
579 512MB
Hi

I A Working On Vb As Front End And Sqlplus As Back End. I Want That Wehn I Enter A New Record In A Database Through Vb, The Form Number Field Automatically Increments Itself By 1.
u may try it in vb as
Expand|Select|Wrap|Line Numbers
  1.  
  2. dim newId&
  3. newId=GenrateNewId(<Column name>,<tableName>)
  4.  
  5. private function GenrateNewId(sColName$,sTblName$)as long
  6. dim ssql$
  7. dim Rs0 as new Adodb.Recordset
  8. dim Conn as new Adodb.Connection
  9. Conn.open <Connstr>
  10. ssql="select nvl(max(" & sColName & "),0)+1 from " & sTblName
  11. Rs0.open ssql,Conn
  12. genratenewid=rs0(0)
  13. rs0.close:set rs0=nothing
  14. Conn.close
  15. end sub
  16.  
This code is not written using vb editor so pls check errors
or u may use Trigger for that
Feb 24 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

11 posts views Thread by Kostatus | last post: by
117 posts views Thread by Peter Olcott | last post: by
18 posts views Thread by Ian Stanley | last post: by
28 posts views Thread by Jon Davis | last post: by
6 posts views Thread by Ammar | last post: by
2 posts views Thread by Mike Collins | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by Mortomer39 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.