Results 1 to 2 of 2

Thread: Generate auto number in textboxes in vb.net

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2014
    Posts
    7

    Generate auto number in textboxes in vb.net

    Hi
    I am generating an auto number in a textbox in vb.net 2010. My connection is totally right and it inserts data very well.
    I used this code function

    sub GetAutoNumber()
    dim d as integer

    dim da as new sqldataadapter("Select table_id from Table_Name", conn)
    if da.Fill(ds, "tableName") then

    d=ds.tables("tableName").rows.count +1
    textbox1.text=d
    else
    textbox1.text=1

    end Sub


    // ds is a dataset in the above code.


    I called this function in page_load, it works properly but the problem is that when ever i run it for the first time it generates the key and I have to enter the data twice after that it will proceed.
    For example i run my program it generates a key then i have to enter the same key generated twice after that it will extend one + one + one. for the first time i have to enter twice, This happens every time i run my program.

  2. #2
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,020

    Re: Generate auto number in textboxes in vb.net

    Hi,

    Code:
    I called this function in page_load
    Is this an ASP.NET application? Aside from page load, does GetAutoNumber() method get called after postback such as button click?

    KGC
    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal | Programming
    Projects: GitHub | jsFiddle
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width