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
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