471,853 Members | 1,869 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,853 software developers and data experts.

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 886
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
NeoPa
reply views Thread by NeoPa | last post: by
reply views Thread by YellowAndGreen | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.