All pastes #197003 Raw Edit

Shin-Ra

public text v1 · immutable
·published 2006-10-11 00:48 UTC
rendered paste body
using System;
using System.Data.SqlClient;

public struct Category
{
    public string Name;
    public Int32 CategoryID;
    public Int32 SortBy;
}
public class SqlData
{
    public SqlData()
    {
    }
    public Category GetCategoryRecord(int CategoryID)
    {
        SqlCommand comm = SqlControls.CreateCommand( );
        comm.Connection.Open( );
        comm.CommandText = "SELECT * FROM Category WHERE CategoryID=@CategoryID";
        comm.Parameters.AddWithValue( "@CategoryID" , CategoryID );
        SqlDataReader r = comm.ExecuteReader( );
        Category details = new Category();
        if (r.Read())
        {
            details.CategoryID = Int32.Parse( r["CategoryID"].ToString( ) );
            details.SortBy = Int32.Parse( r[ "SortOrder" ].ToString( ) );
            details.Name = r[ "Name" ].ToString( );
        }
        r.Close( );
        comm.Connection.Close( );
        return details;
    }
}