I think this should not be a problem. I tried to solve it before, but I did not solve it. Today I finally made up my mind and must solve it. Although it is not needed for the time being, it may be used later. In fact, it is very simple. in SQL Server, there is a global variable @ identity, which is used to record the value automatically added to 1 generated by the current link. This variable can also be used in access, A product.
This blog system cannot upload attachments. I want to convert them into images. After downloading them, we will convert them into RAR extensions and decompress them. This method is different. It seems that code can be pasted.
The following code is written in DOTNET 2.0. It does not matter to other programming languages:
Using system;
Using system. Collections. Generic;
Using system. componentmodel;
Using system. Data;
Using system. drawing;
Using system. text;
Using system. Windows. forms;
Using system. Data. oledb;
Namespace windowsapplication1
{
Public partial class form1: Form
{
Public form1 ()
{
Initializecomponent ();
}
Private void button#click (Object sender, eventargs E)
{
Oledbconnection1.open ();
}
Private void button2_click (Object sender, eventargs E)
{
Oledbcommand1.commandtype = commandtype. text;
Oledbcommand1.commandtext = "insert into T1 (AA) values ('A ')";
Oledbcommand1.executenonquery ();
}
Private void button3_click (Object sender, eventargs E)
{
Oledbcommand1.commandtype = commandtype. text;
Oledbcommand1.commandtext = "select @ identity as id_new ;";
Oledbdatareader DR = oledbcommand1.executereader ();
If (dr. Read ())
{
Label1.text = convert. tostring (INT) Dr ["id_new"]);
}
Else
{
Label1.text = "";
}
Dr. Close ();
}
Private void button4_click (Object sender, eventargs E)
{
Oledbconnection1.close ();
}
}
}
The code is too simple and needless to say.
Add the following knowledge about automatic access numbers:
1. The data type of the automatic serial number is a long integer. The following is a description:
Long (long integer) variables are stored in a 32-bit (4-byte) signed value format, ranging from-2,147,483,648 to 2,147,483,647. Long type declaration character is and (&).
2. If the automatic number starts from 1, it will automatically jump to-2147483647 once it reaches 2147483648, and then scale down until 0.
3. If you reach 1 again, if you define the "Index" attribute of the automatically numbered field as "Yes (no duplicates)" when designing the table, the system will prompt an error. If no value is set, the automatic number continues to increase from 1.