[c#] problem with calling stored procedure

P

Piotrek \Alchemik\

Hello,

i'm trying to call stored procedure like:

ALTER PROCEDURE [dbo].[getValuesDay]
@p1 int,
@p2 Datetime
AS
BEGIN
SET NOCOUNT ON;
SELECT Value, Date FROM [testowa].[dbo].[test1]
WHERE ID_sensor = @p1 AND @p2 = Convert(nchar(10),[Date],102)
END

From ASP web page using c#. The code looks like:

string connectionString =
ConfigurationManager.ConnectionStrings["testowaConnectionString"].ConnectionString;
SqlConnection thisConnection = new
SqlConnection(connectionString);
thisConnection.Open();

SqlCommand command = new SqlCommand("getValuesDay",
thisConnection);

command.Parameters.Add("@p1", SqlDbType.Int).Value=p1;
command.Parameters.Add("@p2", SqlDbType.DateTime).Value=p2;

command.ExecuteNonQuery();

SqlDataAdapter adapter = new SqlDataAdapter(command);

DataTable dt = new DataTable();
adapter.Fill(dt);

GridView1.DataSource = dt;
GridView1.DataBind();
thisConnection.Close();

p1 is int and p2 is a datetime:

ReturnValues(Convert.ToInt32(showSensors.SelectedValue),
Convert.ToDateTime(showDates.SelectedValue));

And this stored procedure is not working. When i don't hand any
parameter it's working fine. What i'm doing wrong?

Thanks in advance

Piotrek
 
?

=?ISO-8859-2?Q?G=F6ran_Andersson?=

Standard question #1:
What do you mean by "not working"?

Standard question #2:
What error message do you get?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top