Click to See Complete Forum and Search --> : want to fetch 40 character from starting.......


asifbhura
07-11-2006, 02:52 AM
Dear

I have stored data in my database table's

I am displaying data in Repeater by using

this code

SqlConnection cnn = new SqlConnection(ConfigurationSettings.AppSettings["DBConnection"]);
cnn.Open();
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "select top 4 blog_title from blogs order by b_date DESC";
cmd.Connection= cnn;

SqlDataAdapter sd = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
sd.Fill(ds);

repblog.DataSource = ds;
repblog.DataBind();
cnn.Close();

this is working ok

but i want only 40 character from my blog_title field from starting

please help me out

Waiting for reply.

regards,
ASIF

Phil Weber
07-11-2006, 02:58 AM
Try:

cmd.CommandText = "select top 4 LEFT(blog_title, 40) from blogs order by b_date DESC";

asifbhura
07-11-2006, 03:06 AM
dear Phil

thank you very much for quick response