Set the field to uniqueidentifier and display it as a 32-bit binary code. The advantage is that when several systems are integrated and do not conflict with the ID, 8-4-4-12 combination;
Public static agent createagent (Agent agent)
{
Iconnection CNN = connectionmanager. getconnection ();
CNN. open ();
Itransaction trans = CNN. begintransaction ();
Icommand cmd;
Int I = 0;
Int deletedrows = 0;
Guid agentid = guid. newguid ();
String SQL = "insert into [B2B _agent] ("
+ "[Agentid], [Code], [type], [level],"
+ "[CompanyName], [companynameshort], [provincecode], [citycode],"
+ "[Address], [postcode], [linkman], [email], [tel],"
+ "[Mobiletel], [MSN], [QQ], [isprovider], [ispurchaser], [State], [registerdate], [introducer], [commisionmode])"
+ "Values ("
+ "?, '',?, ?, "
+ "?, ?, ?, ?, "
+ "?, ?, ?, ?, ?, "
+ "?, ?, ?, ?, ?, ?, Getdate (),'',?) ";
Cmd = CNN. createcommand (SQL );
Cmd. Transaction = trans;
Cmd. setguid (I, agentid); I ++;
Cmd. setint (I, agent. type); I ++;
Cmd. setint (I, agent. Level); I ++;
Cmd. setnvarchar (I, agent. companyName); I ++;
Cmd. setnvarchar (I, agent. companynameshort); I ++;
Cmd. setint (I, agent. provincecode); I ++;
Cmd. setint (I, agent. citycode); I ++;
Cmd. setnvarchar (I, agent. Address); I ++;
Cmd. setvarchar (I, agent. postcode); I ++;
Cmd. setnvarchar (I, agent. linkman); I ++;
Cmd. setvarchar (I, agent. Email); I ++;
Cmd. setvarchar (I, agent. Tel); I ++;
Cmd. setvarchar (I, agent. mobiletel); I ++;
Cmd. setvarchar (I, agent. MSN); I ++;
Cmd. setvarchar (I, agent. qq); I ++;
Cmd. setbit (I, agent. isprovider); I ++;
Cmd. setbit (I, agent. ispurchaser); I ++;
Cmd. setint (I, agent. State); I ++;
Cmd. setint (I, agent. commisionmode); I ++;
// Cmd. setbit (I, agent. isprovider); I ++;
// Cmd. setbit (I, agent. ispurchaser); I ++;
Try
{
Deletedrows = cmd. executenonquery ();
}
Catch (exception E)
{
Goto error;
}
If (! (Deletedrows> 0 ))
{
Goto error;
}
Trans. Commit ();
CNN. Close ();
Return getagentbyid (agentid );
Error:
Trans. rollback ();
CNN. Close ();
Return NULL;
}"? "To prevent code confusion; or delete Table1 where a = 1 or 1 = 1
Declare @ A varchar set @ A = '1 or 1 = 1'
Delete Table1 where a = @