C# Webservice SQL and how to return a result
Posted on 2008-11-08
Hi everyone and thanks in advance for your help.
I am trying to create a web service that uses an input parameter and outputs a string
Example = input parameter = 'Hi'
Result = 'Hi thanks for stopping by my web service"
I have created and test the Proc and the proc reads like this
select output1 from table where input1 = @input1
ouput1 is a nvarchar (255)
Now my webservice is working but it is returning a 0 for the results
public int GetTextResponse(string filter)
string connString = "Server= xxx ;Initial Catalog=TIRES;Persist Security Info=True;User ID=sa; Password=xxxx;";
using (SqlConnection sc = new SqlConnection(connString))
using (SqlCommand cmd = new SqlCommand ("usp_GetTextResponse",sc))
cmd.CommandType = CommandType.StoredProcedure;
//cmd.Parameters["OutPut1"].Direction = ParameterDirection.ReturnValue;
cmd.Parameters["@Input1"].Value = filter;
What am I doing wrong ?
I know it is in this line of code
but am not sure what I need to do to fix
I know I could create a data set and return the output in the dataset ....but sense there is on one output and it is a nvarchar(255) ...I thought they would be some way just to return a string...Is a dataset the best way to go?
Thanks in advance for your help