my client has dataGridveie control and i was trying to load a DataTable, a row of values based on search by code,
here my dal:
Java
public static DataTable GetBrands(string code)
{
SqlConnection g_conn;
SqlCommand g_cmd;
DataSet g_ds = new DataSet();
SqlDataAdapter g_da = new SqlDataAdapter();
SqlParameter pRowVersion;
try
{
using (g_conn = new SqlConnection( ConnectionStringBuild.GetConnectionString()) )
{
g_da.SelectCommand = new SqlCommand();
g_da.SelectCommand.CommandType = CommandType.StoredProcedure;
g_da.SelectCommand.CommandText = "TestSearchBrandsByCode";
g_da.SelectCommand.Connection = g_conn;
SqlParameter pBrandCode = new SqlParameter("@PBrandCode", SqlDbType.NChar, 6)
{ Direction = ParameterDirection.InputOutput, Value = code };
g_da.SelectCommand.Parameters.Add(pBrandCode);
g_da.SelectCommand.Parameters.Add("@PBrandID", SqlDbType.Int, -1).Direction = ParameterDirection.Output;
g_da.SelectCommand.Parameters.Add("@PShortName", SqlDbType.NVarChar, 50).Direction = ParameterDirection.Output;
g_da.SelectCommand.Parameters.Add("@PFullName", SqlDbType.NVarChar, 100).Direction = ParameterDirection.Output;
pRowVersion = new SqlParameter("@PRowVersion", SqlDbType.VarBinary, -1)
{ Direction = ParameterDirection.Output, SourceVersion = DataRowVersion.Original };
g_da.SelectCommand.Parameters.Add(pRowVersion);
g_da.SelectCommand.Connection.Open();
g_da.Fill(g_ds);
g_da.SelectCommand.Connection.Close();
return g_ds.Tables[0];
}
}
catch
{
throw;
}
}SQL
ALTER PROC TestSearchBrandsByCode
@PBrandCode nchar(6) OUTPUT,
@PBrandID int OUTPUT,
@PShortName NVARCHAR(50) OUTPUT,
@PFullName NVARCHAR(100) OUTPUT,
@PRowVersion TIMESTAMP OUTPUT
AS
BEGIN
SELECT
BrandID = @PBrandID,
BrandCode = @PBrandCode,
ShortName = @PShortName,
FullName = @PFullName,
RVersion = @PRowVersion
FROM tblBrands
WHERE BrandCode = @PBrandCode
END
GO
How do i fix this error?
thanks

Sam HobbsRank #107 · 20.5K reputationPosted Mar 6, 2010, 11:21 PM EST
Are you sure that the PBrandCode, PBrandID, PShortName, PFullName and PRowVersion parameters are valid? Are the names and types correct for the fields?