Hi Every body
I have a serial no in my application like this : A-33-1
the last no is increment in my application starting from 0 i want to make it like this :
A-33-001 so it should start from 000 how can i make it default value in SQL table 000 insted
of 0
Loading
VulpesPosted Mar 17, 2013, 1:25 PM
If you run these lines in isolation it definitely changes "1" to "001":
ToBePosted Mar 18, 2013, 3:31 AM
using what you suggested (D3)
ToBePosted Mar 17, 2013, 11:02 AM
VulpesPosted Mar 16, 2013, 9:33 AM
cmd.Parameters.AddWithValue(@My_No , DropDownList1.SelectedValue + " -" + DropDownList2.SelectedValue + " -" + ser_no);
to this:
cmd.Parameters.AddWithValue(@My_No , DropDownList1.SelectedValue + " -" + DropDownList2.SelectedValue + " -" + int.Parse(ser_no).ToString("D3"));
then I think that should do what you want.
Instead of int.Parse(ser_no) you could also use 'x' if it's still in scope.
brunda kPosted Mar 16, 2013, 7:35 AM
ToBePosted Mar 16, 2013, 7:25 AM
the first part is string value reading from Dropdown
the seconed is variable reading from another dropdownlist
only the last part is int incrementing when user click save .
my code is like this :
int X=0;
cmd.CommandText = "select [serial] from tblActivites where id=" + int.Parse(DropDownList1.SelectedValue);
cmd.Connection = con;
con.Open();
SqlDataReader dr = cmd.ExecuteReader();
dr.Read();
x = int.Parse(dr[0].ToString());
x++;
string ser_no = x.ToString();
dr.Close();
this is to read the latest serial no (last part )for each selected item for the Dropdownlist
and i pass the three parts to my stored procedure like this :
cmd.Parameters.AddWithValue(@My_No , DropDownList1.SelectedValue + " -" + DropDownList2.SelectedValue + " -" + ser_no)
my problem is that the last value incrementing like this : o, 1, 2, 3, 4
and i want it to be incremented like this : 000,001,002,003 and so on
this is my table :
how to apply it here ??
VulpesPosted Mar 15, 2013, 7:59 PM