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;}}
ALTER PROC TestSearchBrandsByCode@PBrandCode nchar(6) OUTPUT,@PBrandID int OUTPUT, @PShortName NVARCHAR(50) OUTPUT, @PFullName NVARCHAR(100) OUTPUT, @PRowVersion TIMESTAMP OUTPUTASBEGINSELECT BrandID = @PBrandID, BrandCode = @PBrandCode, ShortName = @PShortName, FullName = @PFullName, RVersion = @PRowVersionFROM tblBrandsWHERE BrandCode = @PBrandCodeENDGO