.Net Basic

This blogs gives introduction to C#.NET programming for beginners. This blogs assumes that you have no programming experience whatsoever. It's a lot easier than you think, and can be a very rewarding hobby!after Refer this blog

26 June 2009

DataGridView add Column and row Programatically in c#.net

dataGridView1.Columns.Add(ColumnName , ColumnHeader Text);


DtView.Rows.Add(Number of Row);

Labels:

Call SELECT Stored Procedure in c#.net

Main

String strStoreProcName = "Store Procedure Name";
SqlCommand cmd = new SqlCommand(strStoreProcName);
//Add number of Paramaters
cmd.Parameters.AddWithValue("@Parameter Name in datebase", Parameter value);
datatable = GetData(cmd);

Function

public DataTable GetData(SqlCommand cmd)
{

DataTable dt = new DataTable();

String strConnString= System.Configuration.ConfigurationManager.ConnectionStrings["conString"].ConnectionString;


SqlConnection con = new SqlConnection(strConnString);

cmd.Connection = con ;

SqlDataAdapter sda = new SqlDataAdapter();

cmd.CommandType = CommandType.StoredProcedure;

try
{

con.Open();

sda.SelectCommand = cmd;

sda.Fill(dt);

}

catch (Exception ex)
{

return dt;

}

finally
{

con.Close();

cmd.Dispose();

sda.Dispose();

}

return dt;

}

Labels:

Marquee in c#.net windows Application

Note:
Make Use of timer control and write this below function in Timer control Ticker Events and also Set timer Enabled = true
private void TmrPPT_Tick(object sender, EventArgs e)
{

string strScrollText= " Welcome to .Netbasic";
if (!(intPosition <= strScrollText.Length))
{
intPosition = 0;
}
LblScrollingText.Text = strScrollText.Substring(intPosition);
intPosition = intPosition + 1;

}

Labels: ,

Compare 2 different dates without seconds in sqlserver 2005

select
(convert(varchar(10),DateTime1,103) + ' ' + convert(varchar(5),DateTime1,108))
,convert(varchar(10),DateTime2,103)+ ' '+ convert(varchar(5),DateTime2,108) from MIB_Time_Scheduling
where convert(varchar(10),DateTime1,103) = convert(varchar(10),DateTime1,103) and convert(varchar(5),DateTime2,108)=convert(varchar(5),DateTime2,108)

Labels: , ,