473,396 Members | 1,858 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Increment Number

I am relatively new to the C# scene so I am a lot of rough around the edges. Anyways I am trying to pull a number value from an Access DB starting at 8000 and increment that value by one every time a user enters a new row into the Access DB, and then get that number to reset daily back to 8000. Also having that incremented number show up in a textbox once the user has pushed the data into the Access DB. I have a rough draft of some code, but of course, I have no clue if I am even starting off in the right direction. I am assuming most of the what I need will have to be based on the query of the OleDbConnection.

Expand|Select|Wrap|Line Numbers
  1.         protected void GetSerialNumber()
  2.         {
  3.             OleDbConnection db = new OleDbConnection(dbstr);
  4. //Here is where I can't get a fix on writing a proper query to get the last number from the Access DB and increment it.
  5.             string query = ;
  6.             try
  7.             {
  8.                 db.Open();
  9.  
  10.                 try
  11.                 {
  12.                     OleDbCommand command = new OleDbCommand();
  13.                     command.CommandText = query;
  14.                     command.Connection = db;
  15.                     command.ExecuteNonQuery();
  16.                 }
  17.                 catch (Exception e)
  18.                 {
  19.                     MessageBox.Show(e.Message);
  20.                 }
  21.             }
  22.             catch (Exception e)
  23.             {
  24.                 MessageBox.Show(e.Message);
  25.             }
  26.             finally
  27.             {
  28.                 db.Close();
  29.             }
  30.         }
  31.  
I don't have any code to reset that number daily or being able to show the incremented number after the user has submitted the data into the DB, as I don't even know where to even begin on that part of the code. Any help on this would be greatly appreciated.
May 15 '17 #1
0 1248

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

Similar topics

6
by: Kd | last post by:
I have the OrderNo set as the following Right(Format(Date(),"yyyy"),1) & Format(Date(),"mm") & "-"Format(,"000")+1 This works great until I get to a new month and need the numbers to reset like...
2
by: x0054 | last post by:
Ok, this is a stupid problem, I admit. I have a scrip that adds records to a table. The records are for photos. So, after adding a record the scrip also uploads a picture from users computer and...
3
by: nfrjob | last post by:
Hi there, I'm an advanced beginner, so please bear with me... I have a simple table that has four fields in it: Zone (which will store a three letter code such as ABC), Year (a four digit number...
27
by: 3acks | last post by:
I've read a lot of articles and forums trying to figure this one and have yet to come up with a solution I can get to work. I need to create a unique id. I can do this using Dmax to find the...
3
by: Kuba S | last post by:
Hi, I'm trying to do below numbering in access: apple 1 apple 2 apple 3 apple 4 orange 1 orange 2
1
by: DANY IGHNATIOS | last post by:
hi. i want to update a row in an ACCESS DB in vb.net using sql query. the way to point to the row is using the primary key. the problem is that i was an error saying that there is a data type...
18
by: Tony Liane | last post by:
I am using Access 2003 and I need your help. I have a "Contribution Summary Query" that adds up all year members contribution. In the query I have to generate a Receipt No. to each recordset in the...
3
by: SDaxx | last post by:
I am new to access and vba and am trying to have a text field (txtFiscalYear) increment by one on October 1 of each year. For example on 9/30/2013 the field is 2013 and then on October 1, 2013 the...
4
by: sanjass80 | last post by:
Hi i have a field called "wosubID" which is the work order issued for subcontractors which is the primary key. i want to have the code generated in the following format, mmyy-increment numbers. ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.