Declare @table nVarchar(1000)
set @table = 'select * from ' + @table_name
exec(@table)
Run Store Procedure
Exec select_table_dynamic 'table_name'
Run Store Procedure
Exec select_table_dynamic 'table_name'
Before go in for export,just configure ur Database Driver With the Given Code Below.
EXEC sp_configure 'show advanced options', 1;
Below Code is used to Export Sql Data into Excel Format
Add references of Microsoft office components from com tab.
Include the header file
Using System.OWC;
//Create chartspace object to hola a chart
OWC.ChartSpace draw_chart = new OWC.ChartSpace();
//Add a chart in chartspace
OWC.WCChart chart_obj = draw_chart.Charts.Add(0);
//specify the type of chart to be displayed
chart_obj.Type = OWC.ChartChartTypeEnum.chChartTypeColumnClustered;
//specify the chart legend value,if it is needed.
chart_obj.HasLegend = true;
//set the chart caption on or off and set the caption value of chart.
chart_obj.HasTitle = true;
chart_obj.Title.Caption = "Demo Chart";
//set the caption of x and y axis positions
chart_obj.Axes[0].HasTitle = true;
chart_obj.Axes[0].Title.Caption = "POSITION X";
chart_obj.Axes[1].HasTitle = true;
chart_obj.Axes[1].Title.Caption = "POSITION Y";
//creating a values for a chart
String bar_name = "Line 1";
string x_values = "1" + '\t' + "2" + '\t' + "3";
string y_values = "1" + '\t' + "2" + '\t' + "3";
//add the seriescollection in chart chart object
chart_obj.SeriesCollection.Add(0);
//Binding the chart values in seriescollection array.
chart_obj.SeriesCollection[0].SetData(OWC.ChartDimensionsEnum.chDimSeriesNames, (int)OWC.ChartSpecialDataSourcesEnum.chDataLiteral, bar_name);
chart_obj.SeriesCollection[0].SetData(OWC.ChartDimensionsEnum.chDimCategories, (int)OWC.ChartSpecialDataSourcesEnum.chDataLiteral, x_values);
chart_obj.SeriesCollection[0].SetData(OWC.ChartDimensionsEnum.chDimValues, (int)OWC.ChartSpecialDataSourcesEnum.chDataLiteral, y_values);
//specify the chart export path.
string chart_path = "chart.gif";
draw_chart.ExportPicture(chart_path, "gif", 500, 500);
//chart file name to be displayed
string gif_file_path = "chart.gif";
//binding the filename into a image tag.
string img_tag="include image tag here with file source name of chart file name mentioned above";
//Add a imagetage into a placedholder to view the chart
chart_container.Controls.Add(new LiteralControl(img_tag));
Creating New XmlFile
XmlTextWriter xml_writer = new XmlTextWriter(Server.MapPath(path), null);
xml_writer.WriteStartDocument();
xml_writer.WriteRaw("");
xml_writer.WriteStartElement("Login_Details");
xml_writer.WriteEndElement();
xml_writer.WriteEndDocument();
xml_writer.Close();
For Updating Attributes Value OF Xml
XmlDocument xml_Doc = new XmlDocument();
xml_Doc.Load(Server.MapPath(path));
XML Files
Create Xml File then use the below code to access.
C# Codings
int i, j;
Creating Of Deletecates Events
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
namespace delegates
{
///
/// Summary description for Delegates
///
public class Delegates : System.Collections.ArrayList
{
public event System.EventHandler changed;
protected virtual void Onchanged(System.EventArgs e)
{
if (changed != null)
{
changed(this, e);
}
}
public override int Add(object value)
{
int i = base.Add(value);
Onchanged(System.EventArgs.Empty);
return i;
}
public Delegates()
{
//
// TODO: Add constructor logic here
//
}
}
}
Creation Of EventHander and Fucntions
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
///
/// Summary description for delegates_list
///
///
using delegates;
namespace delegates_list_pro
{
public class delegates_list
{
private Delegates list1;
public delegates_list(Delegates alist)
{
list1=alist;
list1.changed+=new System.EventHandler(listadded);
}
private void listadded(object sender,EventArgs e)
{
System.Windows.Forms.MessageBox.Show("WELCOME");
}
public void Detach()
{
list1.changed-=new System.EventHandler(listadded);
list1=null;
}
public delegates_list()
{
//
// TODO: Add constructor logic here
//
}
}
}
Calling Detlegates and its event handlers from the main program
using delegates;
using delegates_list_pro;
Delegates dele = new Delegates();
delegates_list listener = new delegates_list(dele);
dele.Add("Welcome");
dele.Clear();
listener.Detach();
For More Information View this link
http://code.google.com/apis/ajaxsearch/documentation/#AJAX_Loader