Problem with SqlDbType.TinyInt

  • Thread starter Thread starter valmir cinquini
  • Start date Start date
V

valmir cinquini

Hi everybody

I'm newbee in C# and I'm supporting an application where there's a
method like following:

public int addNews(DateTime dtNews, string strTitle, string
strShortText, string strText, int intStatus)

When trying to add the data to a SqlServer 2K using ADO.Net I did the
following:

< SqlCommand and SqlConnection here >

cm.Parameters.Add(new SqlParameter("@intStatus",SqlDbType.TinyInt, 1,
intStatus));

I've got the error message:
\\ssp05\wwwroot$\News.cs(40): Argument '4': cannot convert from 'int'
to 'string'

I know I might doing something stupid, but I can't figure out what it
is. Any help would by very appreciated. Thanks.
 
The Fourth parameter where you have intStatus is supposed sourceColumn which
is a string...so just change it to

cm.Parameters.Add(new SqlParameter("@intStatus",SqlDbType.TinyInt,1 )).Value
=intStatus); I may have messed up the Parenthesis;
or you could just do cm.Parameters.Add(new SqlParameter("@intStatus",
SqlDbType.TinyInt,1));
cmd.Parameters("@intStatus") = intStatus;
 
Look up the constructors for SqlParameter!
You are trying to pass (string, SqlDbType, int, int) to the constructor and
the closest matching constructor is (string, SqlDbType, int, string).

Regards, Mikael
 
Back
Top