Why this code don't work,when i want run this code vwd 2008 express show me this error message:Invalid object name 'answers'.
this is my ascx.cs code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.Data.SqlClient;
using System.Configuration;
public partial class odgl : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
string connectionString =
@"SANATIZEDSTRING!!!!";
using (SqlConnection cn = new SqlConnection(connectionString))
{
using (SqlCommand dohvati = new SqlCommand("dbo.get_answers",cn)) {
dohvati.CommandType = CommandType.StoredProcedure;
SqlParameter izracun = new SqlParameter("@count", SqlDbType.Int);
izracun.Direction = ParameterDirection.Output;
dohvati.Parameters.Add(izracun);
cn.Open();
dohvati.ExecuteNonQuery();
int count = Int32.Parse(dohvati.Parameters["@count"].Value.ToString());
Response.Write(count.ToString());
cn.Close();
}
}
}
}
and this is my stored procedure
:
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[get_answers]
@ukupno int output
as
select @count= (SELECT COUNT(*) FROM answers)
go