Wednesday 26 December 2012

Add News Feed in Web Page

 Write the below Javascript code in the source code of your web page :

<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<
script src="http://www.google.com/uds/solutions/dynamicfeed/gfdynamicfeedcontrol.js"type="text/javascript"></script><
style type="text/css">@import
url("http://www.google.com/uds/solutions/dynamicfeed/gfdynamicfeedcontrol.css");#feedControl {margin-top : 10px;margin-left: auto;margin-right: auto;width : 205px;font-size: 12px;color: #9CADD0;}
</style><
script type="text/javascript">function
load() {
var feed = "http://rss.cnn.com/rss/edition_world.rss";new GFdynamicFeedControl(feed, "feedControl");}
google.load(
"feeds", "1");google.setOnLoadCallback(load);
</script>

---The variable Feed conatins the site from where the news are fetched. We can give some other sites too such as :
1. var feed =”http://feeds.bbci.co.uk/news/world/rss.xml”;
2. var feed =”http://rss.cnn.com/rss/edition_world.rss”;
3. var feed =”http://feeds.reuters.com/Reuters/worldNews “;
Now where ever you need the news feed in your page just write the below code :


<div id="feedControl" align="left" dir="ltr">Loading...&nbsp; </div>


You can see the page with active news feeds along with the link :

Thursday 20 December 2012

OLEDB: Extract The Data from Excel and Show it in Gridview or add to database table

Let the excel sheet contains the above data along with the header. Now in the application, take a fileupload control, a button and a gridview. In the botton click write the below code :

try
{DataSet ds = new DataSet();//file upload pathstring path = FileUpload1.PostedFile.FileName;
//Create connection string to Excel work bookstring excelConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties=Excel 12.0;Persist Security Info=False";
//Create Connection to Excel work book
OleDbConnection excelConnection = new OleDbConnection(excelConnectionString);

//Create OleDbCommand to fetch data from ExcelOleDbCommand cmd = new OleDbCommand("Select [EID],[LOB],[Resource First Name],[Resource Middle Initial],[Resource Last Name],[Primary Role],[Input Type Code],[Financial Location],[Currency Code],[Actual Payable Hours] from [Sheet1$]", excelConnection);
OleDbDataAdapter da = new OleDbDataAdapter(cmd);da.Fill(ds);
excelConnection.Open();

OleDbDataReader dReader;dReader = cmd.ExecuteReader();

//SqlBulkCopy sqlBulk = new SqlBulkCopy(strConnection);////Give your Destination table name//sqlBulk.DestinationTableName = "Excel_table";//sqlBulk.WriteToServer(dReader);excelConnection.Close();GridView1.DataSource = ds;
GridView1.DataBind();
catch (Exception ex)
{
        Response.Write(ex.StackTrace);
}

The Result will look as below :

Now since we got the data in dataset from the excel, we can easily do anything we need with the data(modify) and insert it in the database table.