Recently, I kept getting above mentioned error. My code looked like this:
protected void btnUploadSubmit_Click(object sender, EventArgs e)
{
/* here goes code for uploading Excel file and filling DataTable called excelTable*/ BackEndTableAdapters.RegistrantsTableAdapter reg = new BackEndTableAdapters.RegistrantsTableAdapter();
{
int ID=0; // source of evil string firstName = excelRow[“First Name”].ToString();
string lastName = excelRow[“Last Name”].ToString();
/* … */
reg.AddRegistrant(firstName, lastName,……, ref ID); /*this is the line that generates error; ID is output parameter of stored procedure */
}
/* … */ }
What was wrong with this code? Well, last argument of AddRegistrant function was nullable int (int?) and not int. When I changed line
int ID=0;into
int? ID=0;everything went well..
Make money with this.:)
The main thing i’m enjoying while reading your blog is the way you write, you are a really charismatic person and your posts are wonderful, keep it up!
By: health on November 24, 2007
at 10:21
This was driving me insane! Thanks for posting!
By: Raj Parmar on July 17, 2008
at 06:40
hi this is vadluri sreenu,
you should delcare ID like this.
int? ID;
insted of int ID;
it solves your problem.
By: Vadluri Sreenu on November 15, 2008
at 06:04
This was driving me insane also…
Thanks for finding this *NOT* well documented tidbit.
By: david schneider on December 11, 2008
at 00:53
Hello webmaster
I would like to share with you a link to your site
write me here preonrelt@mail.ru
By: Alexwebmaster on March 3, 2009
at 12:44
Hi,
I would be happy to exchange link with you. Mine is, as you know, https://developerstips.wordpress.com 🙂
Cheers, m8!
By: Draško Sarić on March 6, 2009
at 10:57