protected void Page_Load(object sender, EventArgs e)
{
autogenerated(); //its a call for auto no. function
}
void autogenerated()
{
string connection = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlConnection con = new SqlConnection(connection);
str = "select max(abid) as abid from abstracted";
com = new SqlCommand(str, con);
con.Open();
count = Convert.ToInt16(com.ExecuteScalar()) + 1;
Label1auto.Text = "AB00" + count.ToString();
con.Close();
}Html code
<asp:Label ID="Label1auto" runat="server"
Visible="true"></asp:Label>Data table scripts
CREATE TABLE [dbo].[abstracted](
[id] [int] IDENTITY(1,1) NOT NULL,
[abid] [nvarchar](255) NULL,
[abno] [nvarchar](255) NULL,
[abtype] [nvarchar](255) NULL,
[category] [nvarchar](255) NULL,
[name] [nvarchar](255) NULL,
[design] [nvarchar](255) NULL
) ON [PRIMARY]Web config
<connectionStrings>
<!--<add name="ConnectionString" connectionString=" Data Source=.\SQLEXPRESS;database=dmcg_admin;Integrated Security=True" providerName="System.Data.SqlClient" />-->
</connectionStrings>Output
Auto no -AB001
