EDN Admin
Well-known member
Hi,
i am trying to accumulate a total into my variable of type int called targetTotal which corressponds to my text box called
<span style="font-size:x-small; font-family:Consolas <span style="font-size:x-small; font-family:Consolas totaltargettxtbx which is then meant to be sent to my ms access database via a button submit into a field called targetTotal of type Long Integer, but
when i try to run my form i get an error saying: Input string was not in a correct format. which points to this line
<span style="font-size:x-small; font-family:Consolas <span style="font-size:x-small; font-family:Consolas <span style="font-size:x-small; font-family:Consolas <span style="font-size:x-small; font-family:Consolas
targetTotal =
<span style="font-size:x-small; font-family:Consolas
<span style="font-size:x-small; color:#2b91af; font-family:Consolas <span style="font-size:x-small; color:#2b91af; font-family:Consolas <span style="font-size:x-small; color:#2b91af; font-family:Consolas Convert<span style="font-size:x-small; font-family:Consolas <span style="font-size:x-small; font-family:Consolas .ToInt32(totaltargettxtbx.Text);
<span style="font-size:x-small; font-family:Consolas <span style="font-size:x-small; font-family:Consolas i scoured the net for a while now and i noticed that i have to check for a null value which i am trying to do given the following code:
<div style="color:black; background-color:white
<pre> <span style="color:blue int targetOneDay =0;
<span style="color:blue int targetTwoDay = 0;
<span style="color:blue int targetFiveDay = 0;
<span style="color:blue int targetTenDay = 0;
<span style="color:blue int targetTotal =0;
<span style="color:blue int total = 0;
targetOneDay = Convert.ToInt32(nine_to_fourteenhrstxbx.Text);
targetTwoDay = Convert.ToInt32(fifteen_to_fortfourglhtxtbx.Text);
targetFiveDay = Convert.ToInt32(fourtyfive_to_74txtbx.Text);
targetTenDay = Convert.ToInt32(min75glhtxtbx.Text);
targetTotal = Convert.ToInt32(totaltargettxtbx.Text);
targetTotal += targetOneDay + targetTwoDay + targetFiveDay + targetTenDay;
<span style="color:blue if (totaltargettxtbx.Text != <span style="color:blue null)
total = targetTotal;
<span style="color:blue else
total = 0;
[/code]
<span style="font-size:x-small; font-family:Consolas <span style="font-size:x-small; font-family:Consolas but when doing so i still get the same error message: Input string was not in a correct format. pointing to the same line i.e
<span style="font-size:x-small; font-family:Consolas <span style="font-size:x-small; font-family:Consolas <span style="font-size:x-small; font-family:Consolas <span style="font-size:x-small; font-family:Consolas
targetTotal =
<span style="font-size:x-small; font-family:Consolas
<span style="font-size:x-small; color:#2b91af; font-family:Consolas <span style="font-size:x-small; color:#2b91af; font-family:Consolas <span style="font-size:x-small; color:#2b91af; font-family:Consolas Convert<span style="font-size:x-small; font-family:Consolas <span style="font-size:x-small; font-family:Consolas .ToInt32(totaltargettxtbx.Text);
<span style="font-size:x-small; font-family:Consolas <span style="font-size:x-small; font-family:Consolas please tell me why i get this message and how i can rectify please
full code
<pre lang="x-c# private void submitbtn_Click(object sender, EventArgs e)
{
string projectName;
string startDate;
string endDate;
int targetOneDay =0;
int targetTwoDay = 0;
int targetFiveDay = 0;
int targetTenDay = 0;
int targetTotal =0;
int total = 0;
string dbinsert;
projectName = Convert.ToString(nametxtbx.Text);//nametxtbx.Text;
startDate = startdatetimepcker.Value.ToString();
endDate = enddatetimepcker.Value.ToString();
targetOneDay = Convert.ToInt32(nine_to_fourteenhrstxbx.Text);
targetTwoDay = Convert.ToInt32(fifteen_to_fortfourglhtxtbx.Text);
targetFiveDay = Convert.ToInt32(fourtyfive_to_74txtbx.Text);
targetTenDay = Convert.ToInt32(min75glhtxtbx.Text);
targetTotal += targetOneDay + targetTwoDay + targetFiveDay + targetTenDay;
if (totaltargettxtbx.Text != null)
total = targetTotal;
else
total = 0;
targetTotal = Convert.ToInt32(totaltargettxtbx.Text);
cmd = null;
dbinsert = "INSERT into Project(projectName, startDate, endDate, duration, targetOne, targetTwo, targetFive, targetTen, targetTotal)" +
"VALUES" + "("+""+projectName+""+"," + "" + startDate+""+","+""+endDate+""+","+"5"+","+targetOneDay+"," + targetTwoDay+","+targetFiveDay+","+targetTenDay+","+total+ ")";
cmd = new OleDbCommand(dbinsert, con);
cmd.ExecuteNonQuery();
cmd.Dispose();
con.Close();
}
[/code]
View the full article
i am trying to accumulate a total into my variable of type int called targetTotal which corressponds to my text box called
<span style="font-size:x-small; font-family:Consolas <span style="font-size:x-small; font-family:Consolas totaltargettxtbx which is then meant to be sent to my ms access database via a button submit into a field called targetTotal of type Long Integer, but
when i try to run my form i get an error saying: Input string was not in a correct format. which points to this line
<span style="font-size:x-small; font-family:Consolas <span style="font-size:x-small; font-family:Consolas <span style="font-size:x-small; font-family:Consolas <span style="font-size:x-small; font-family:Consolas
targetTotal =
<span style="font-size:x-small; font-family:Consolas
<span style="font-size:x-small; color:#2b91af; font-family:Consolas <span style="font-size:x-small; color:#2b91af; font-family:Consolas <span style="font-size:x-small; color:#2b91af; font-family:Consolas Convert<span style="font-size:x-small; font-family:Consolas <span style="font-size:x-small; font-family:Consolas .ToInt32(totaltargettxtbx.Text);
<span style="font-size:x-small; font-family:Consolas <span style="font-size:x-small; font-family:Consolas i scoured the net for a while now and i noticed that i have to check for a null value which i am trying to do given the following code:
<div style="color:black; background-color:white
<pre> <span style="color:blue int targetOneDay =0;
<span style="color:blue int targetTwoDay = 0;
<span style="color:blue int targetFiveDay = 0;
<span style="color:blue int targetTenDay = 0;
<span style="color:blue int targetTotal =0;
<span style="color:blue int total = 0;
targetOneDay = Convert.ToInt32(nine_to_fourteenhrstxbx.Text);
targetTwoDay = Convert.ToInt32(fifteen_to_fortfourglhtxtbx.Text);
targetFiveDay = Convert.ToInt32(fourtyfive_to_74txtbx.Text);
targetTenDay = Convert.ToInt32(min75glhtxtbx.Text);
targetTotal = Convert.ToInt32(totaltargettxtbx.Text);
targetTotal += targetOneDay + targetTwoDay + targetFiveDay + targetTenDay;
<span style="color:blue if (totaltargettxtbx.Text != <span style="color:blue null)
total = targetTotal;
<span style="color:blue else
total = 0;
[/code]
<span style="font-size:x-small; font-family:Consolas <span style="font-size:x-small; font-family:Consolas but when doing so i still get the same error message: Input string was not in a correct format. pointing to the same line i.e
<span style="font-size:x-small; font-family:Consolas <span style="font-size:x-small; font-family:Consolas <span style="font-size:x-small; font-family:Consolas <span style="font-size:x-small; font-family:Consolas
targetTotal =
<span style="font-size:x-small; font-family:Consolas
<span style="font-size:x-small; color:#2b91af; font-family:Consolas <span style="font-size:x-small; color:#2b91af; font-family:Consolas <span style="font-size:x-small; color:#2b91af; font-family:Consolas Convert<span style="font-size:x-small; font-family:Consolas <span style="font-size:x-small; font-family:Consolas .ToInt32(totaltargettxtbx.Text);
<span style="font-size:x-small; font-family:Consolas <span style="font-size:x-small; font-family:Consolas please tell me why i get this message and how i can rectify please
full code
<pre lang="x-c# private void submitbtn_Click(object sender, EventArgs e)
{
string projectName;
string startDate;
string endDate;
int targetOneDay =0;
int targetTwoDay = 0;
int targetFiveDay = 0;
int targetTenDay = 0;
int targetTotal =0;
int total = 0;
string dbinsert;
projectName = Convert.ToString(nametxtbx.Text);//nametxtbx.Text;
startDate = startdatetimepcker.Value.ToString();
endDate = enddatetimepcker.Value.ToString();
targetOneDay = Convert.ToInt32(nine_to_fourteenhrstxbx.Text);
targetTwoDay = Convert.ToInt32(fifteen_to_fortfourglhtxtbx.Text);
targetFiveDay = Convert.ToInt32(fourtyfive_to_74txtbx.Text);
targetTenDay = Convert.ToInt32(min75glhtxtbx.Text);
targetTotal += targetOneDay + targetTwoDay + targetFiveDay + targetTenDay;
if (totaltargettxtbx.Text != null)
total = targetTotal;
else
total = 0;
targetTotal = Convert.ToInt32(totaltargettxtbx.Text);
cmd = null;
dbinsert = "INSERT into Project(projectName, startDate, endDate, duration, targetOne, targetTwo, targetFive, targetTen, targetTotal)" +
"VALUES" + "("+""+projectName+""+"," + "" + startDate+""+","+""+endDate+""+","+"5"+","+targetOneDay+"," + targetTwoDay+","+targetFiveDay+","+targetTenDay+","+total+ ")";
cmd = new OleDbCommand(dbinsert, con);
cmd.ExecuteNonQuery();
cmd.Dispose();
con.Close();
}
[/code]
View the full article