I am Working on asp.net C# Project that connect to SQL Database (MySQL 2008).Here is my C# Class:
public static DataTable GetUnitByName(string unit)
{
Database db = DatabaseFactory.CreateDatabase();
string sqlCommand = "GetUnitByName";
DbCommand dbCommandWrapper = db.GetStoredProcCommand(sqlCommand);
db.AddInParameter(dbCommandWrapper, "@Unit", DbType.String, unit);
DataSet ds = db.ExecuteDataSet(dbCommandWrapper);
DataTable dt = ds.Tables[0];
return dt;
}
And Here is the Stored Procedure :
alter PROCEDURE [dbo].[GetUnitByName]
(
@Unit nvarchar
)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON
DECLARE @Err int
-- Insert statements for procedure here
select * from Unit where Name=@Unit
SET @Err = @@Error
RETURN @Err
END
I call the Procedure Like this:
DataTable unit1 = Unit.GetUnitByName(per100gText[1]enter code here
); , wich per10gText is a string list.
but it return empty datatable. the connection to sql server, in debuging i see that the procedure can't read the parameter.
Any Help Please.