hi
i have create database with tables using sql server 2008, having table named 'Users'
i have create this stored procedure :
USE [Licenses_DB]
GO
/****** Object: StoredProcedure [dbo].[InsertUser] Script Date: 02/17/2013 23:25:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[InsertUser]
@ID int ,
@userName NVARCHAR(50),
@password NVARCHAR(50)
AS
BEGIN
SET NOCOUNT ON
INSERT INTO dbo.Users
(
UserName,
UserPassword
)
VALUES
(
@userName,
@password
)
END
Go
then i used it inside C# Visual Studio 2010 to execute stored procedure with this code :
SqlConnection conn = new DBConnection().Conn();
try
{
SqlCommand sqlCMD = new SqlCommand("InsertUser", conn);
sqlCMD.CommandType = CommandType.StoredProcedure;
sqlCMD.Parameters.Add(new SqlParameter("@ID", SqlDbType.Int, 50, "ID")).Value = 1;
sqlCMD.Parameters.Add(new SqlParameter("@userName", SqlDbType.NVarChar, 50, "UserName")).Value = userBox.Text.Trim();
sqlCMD.Parameters.Add(new SqlParameter("@password", SqlDbType.NVarChar, 50, "UserPassword")).Value = passwordBox.Text.Trim();
sqlCMD.ExecuteNonQuery();
}
catch(Exception exc)
{
throw new System.ArgumentException(exc.Message);
}
when i run it throw exception "Invalid object name 'dbo.Users'" ???
what is the problem in this code? how can i solve it ?
Best Regards,,