Dear friends,
I want to display form number on form load and save it in the table starting from 1 and incrementing it by 1 and also check for duplicate form number should not get saved in table.. starting from 1 to 2,3,4,5...................... Its should be saved like this in table...
How can i do it plzz help
Loading
Posted May 31, 2011, 7:26 AM
private void button1_Click(object sender, EventArgs e)
{
DataRow dr = dt.Rows[0];
dr.BeginEdit();
dr["Sno"] = Convert.ToInt32(dr["Sno"]) + 1;
dt.EndInit();
dt.AcceptChanges();
textBox1.Text = dt.Rows[0].ItemArray[0].ToString() + dt.Rows[0].ItemArray[1].ToString();
}DataTable dt = new DataTable();
private void Form2_Load(object sender, EventArgs e)
{
dt.Columns.Add(
dt.Columns.Add(
dr[
"Prefix"] = "SS/11-12/"; //Based on your logic get the Prefix details here.dr["Sno"] = 1;
dt.Rows.Add(dr);
dt.AcceptChanges();
textBox1.Text = dt.Rows[0].ItemArray[0].ToString() + dt.Rows[0].ItemArray[1].ToString();
}
Hope this helps you.
new DataColumn("Prefix", Type.GetType("System.String")));dt.Columns.Add(new DataColumn("Sno",Type.GetType("System.Int32")));
DataRow dr = dt.NewRow();
Mayur GujrathiPosted May 31, 2011, 7:14 AM
DECLARE
@ALPHA_VAL CHAR(1) , @INT_VAL VARCHAR(1000)
DECLARE @VAL INT =97, @VAL1 INT =1
WHILE @VAL <= 122
BEGIN
SET @VAL1=1
WHILE @VAL1 < 1000
BEGIN
SET @ALPHA_VAL = CHAR(@VAL)
SET @INT_VAL = CONVERT(CHAR,@VAL1)
SET @INT_VAL= @ALPHA_VAL + @INT_VAL
PRINT @INT_VAL
SET @VAL1 =@VAL1+1
END
SET
@VAL=@VAL+1
END
Kavita BPosted May 31, 2011, 6:48 AM
I want the admission no in this format.. SS/11-12/06 which is 1st 2 are characters next is the academic year and next is the month....Can someone help
Posted May 30, 2011, 7:12 AM
private void button1_Click(object sender, EventArgs e)
{ DataRow dr = dt.Rows[0];
dr.BeginEdit();
dr["Sno"] = Convert.ToInt32(dr["Sno"]) + 1;
dt.EndInit();
dt.AcceptChanges();
textBox1.Text = dt.Rows[0].ItemArray[0].ToString();
}
DataTable dt = new DataTable();
private void Form2_Load(object sender, EventArgs e){
dt.Columns.Add(new DataColumn("Sno",Type.GetType("System.Int32")));
DataRow dr = dt.NewRow();
dr["Sno"] = 1;
dt.Rows.Add(dr);
dt.AcceptChanges();
textBox1.Text = dt.Rows[0].ItemArray[0].ToString();}
Hope this sample helps you.
Kavita BPosted May 30, 2011, 6:45 AM
Yes u got it.. But how do i do it?
Posted May 30, 2011, 6:44 AM
For this you can use, DataTable has the Primarykey option. So, there you can't store duplicate value.
Once the first value is saved into the database table, then you can increate the datatable value and show into the textbox.
Hoep this helps you.
Kavita BPosted May 30, 2011, 6:40 AM
I have a read only textbox which on form load displays a number starting from 1 which is saved in table... next time for next record textbox should display 2 which again will be saved in table as next record and 3 and 4 and so on
Posted May 30, 2011, 6:39 AM
Can't use Identity column in database ?
Mayur GujrathiPosted May 30, 2011, 6:34 AM