I am receiving an error in my application and i can not figure out how to resolve it. Here is the code:
SqlConnection myConnection = new SqlConnection(Confi
myCommand2.Parameters.Add("@TaskName", SqlDbType.NVarChar, 50).Value = t;
t
is a Task
not a string. This should probably by name
.
I think the problem is with this line:
myCommand2.Parameters.Add("@TaskName", SqlDbType.NVarChar, 50).Value = t;
t cannot be converted to a string. You could try t.Name or t.ToString()
(not sure what properties are available on that class off the top of my head.)
In the line:
myCommand2.Parameters.Add("@TaskName", SqlDbType.NVarChar, 50).Value = t;
I think you have to pass t.Name
or t.ToString()
up on the task's name (I don't know it).
t is of type Task
but when you pass it to your stored procedure you are passing it as nvarchar
.
Here is your code:
myCommand2.Parameters.Add("@TaskName", SqlDbType.NVarChar, 50).Value = t;
T is type of Task and and ado try convert it to string
you should put t.GetType().Name
or the real task name here
because we can't pass objects as parameter the only type are known sqltypes
The issue is on this line:
myCommand2.Parameters.Add("@TaskName", SqlDbType.NVarChar, 50).Value = t;
You are passing the task object in instead of the name of the task.