Теперь,
- Если мой продукт (a) будет иметь A0001, A0002 и т. д.
- Если мой продукт (b) будет иметь b0001, b0002, и т.д....
Я пробовал:
int a;
using (SqlCommand command2 =
new SqlCommand("select * from voiceno WHERE ID = '1'", con))
{
con.Close();
con.Open();
SqlDataReader dr;
dr = command2.ExecuteReader();
if (dr.Read())
{
string val = dr["voiceno"].ToString();
if (val == "0")
{
txtinvoiceno.Text = "00001";
}
else
{
a = Convert.ToInt32(dr["voiceno"].ToString());
a = a + 1;
txtinvoiceno.Text = a.ToString("00000");
}
}
}
Моя таблица выглядит так:
CREATE TABLE [dbo].[voiceno](
[ID] [int] IDENTITY(1,1) NOT NULL,
[voiceno] [nvarchar](50) NULL)
Подробнее здесь: https://stackoverflow.com/questions/555 ... th-c-sharp
Мобильная версия