When you use a registry ticket, you need to return the user's registered ID. At this time, the output of the stored procedure is very convenient.
BackgroundCode:
Public Partial Class _ Default: system. Web. UI. Page
{
String Sqlconnectionstring = " Server = (local); initial catalog = dbtest; Integrated Security = true " ;
Protected VoidPage_load (ObjectSender, eventargs E)
{
}
Protected Void Btnsubmit_click ( Object Sender, eventargs E)
{
Sqlconnection con = New Sqlconnection (sqlconnectionstring );
Using (Sqlcommand com = New Sqlcommand ())
{
Try
{
Con. open ();
Com. Connection = Con;
Com. commandtype = Commandtype. storedprocedure;
Com. commandtext = " Add_users " ;
Com. Parameters. Add ( " @ User_name " , Sqldbtype. varchar, 20 );
Com. Parameters [ " @ User_name " ]. Value = This . Txtuser. text;
Com. Parameters. Add ( " @ Pass_word " , Sqldbtype. varchar, 20 ). Value = This . Txtpwd. text;
Com. Parameters. Add ( " @ ID " , Sqldbtype. Int, 4 ). Direction = Parameterdirection. output;
Com. executenonquery ();
This. Lbltip. Text=Com. Parameters [2]. Value. tostring ();
Con. Close ();
}
Catch{}
}
}
}
Stored Procedure Code: (the database has three fields: uid, username, and password)
Create proc [DBO]. [add_users]
(@ User_name varchar ( 20 ), @ Pass_word varchar ( 50 ), @ ID Int Output)
As
Insert into Info (username, password) values (@ user_name, @ pass_word)
Select @ ID = Max (UID) from Info
CompleteProgramDownload: Download