-
Aug 26th, 2014, 12:54 AM
#1
Thread Starter
New Member
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.
-
Aug 26th, 2014, 10:54 AM
#2
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|