3
Answers

Transaction no

Marvin kakuru

Marvin kakuru

12y
1.1k
1

Transaction no

Hi,

I am trying to generate a transaction number for every transaction I enter in my database, so I

Use the following code to select the last number to which I plan to add a "ONE"

qlConnection cn = new SqlConnection("Data Source=KATOTO-PC;Initial Catalog =thyfarm;User ID=sa;Password=Kyozi");

            string sql = ("select MAX(transno) from prodtntransno");

 

            SqlCommand cmd = new SqlCommand(sql, cn);

            cn.Open();

 

            string s1 = cmd.ExecuteScalar().ToString();

            textBox4.Text = s1.ToString();

 

This code will retrieve the last transaction number for example 11111112 to which I will add a "1"

Generating the next number which should be 11111113. Now this is where my problem begins, below the above code I have placed the code below

int a = System.Convert.ToInt32(textBox4.Text);

            int b = System.Convert.ToInt32(textBox5.Text);

            int c = (a + b);

 

            textBox3.Text = c.ToString();

 

this code is intended to add a "1" which is set as the text of textbox5.text, however when I run I get an ERROR!! "Overflow Exception was unhandled – Value was either too large or too small for an int32 "

any help will be highly appreciated.


Answers (3)