Generate linear alphanumeric no, Web application

Posted by Raja_89 under C# on 1/21/2013 | Points: 10 | Views : 796 | Status : [Member] | Replies : 3
Hai Techie

Kindly guide me to generate a linear alphanumeric no
Eg :rr100 ,rr101,rr102-----------etc

Thanks in advance




Responses

Posted by: Kundnani.Rt on: 1/22/2013 [Member] Starter | Points: 25

Up
0
Down
See if this helps..
 Download source file

Raja_89, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Satyapriyanayak on: 1/22/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace Dynamic_generate_id
{
public partial class Form1 : Form
{
string ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["dsn"];
OleDbCommand com;
string str;
int count;

public Form1()
{
InitializeComponent();
}

private void btn_save_Click(object sender, EventArgs e)
{
OleDbConnection con = new OleDbConnection(ConnectionString);
con.Open();
str = "insert into caste(cast_code,cast_desc) values('" + lbl_castecode.Text.Trim() + "','" + txt_castename.Text.Trim() + "')";
com = new OleDbCommand(str, con);
com.ExecuteNonQuery();
con.Close();
MessageBox.Show("Records successfully Inserted");
txt_castename.Text = "";
autogenerated();
}
private void autogenerated()
{
OleDbConnection con = new OleDbConnection(ConnectionString);
str = "select count(*) from caste";
com = new OleDbCommand(str, con);
con.Open();
count = Convert.ToInt16(com.ExecuteScalar()) + 1;
lbl_castecode.Text = "rr10" + count.ToString();
lbl_castecode.Enabled = false;
con.Close();
}

private void Form1_Load(object sender, EventArgs e)
{
autogenerated();
}
}
}

 Download source file

If this post helps you mark it as answer
Thanks

Raja_89, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Kundnani.Rt on: 1/22/2013 [Member] Starter | Points: 25

Up
0
Down
Satyapriyanayak are you getting data from SQL Server and then processing it?

Raja_89, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response