following is the query:
declare @date1 datetime
set @date1 = '1-sep-2008'
select specific_name,last_altered,created from information_schema.routines
where datediff(day,@date1, last_altered) > 0
or
datediff(day,@date1, created) > 0
Thursday, May 21, 2009
Sunday, May 17, 2009
Textbox validation for numeric and other key codes.
function fncInputNumericValuesOnly()
{
if(!(event.keyCode==45||event.keyCode==46||event.keyCode==48||event.keyCode==49||event.keyCode==50||event.keyCode==51||event.keyCode==52||event.keyCode==53||event.keyCode==54||event.keyCode==55||event.keyCode==56||event.keyCode==57))
{
event.returnValue=false;
}
}
< asp:TextBox id="txtQty" runat="server" onkeypress= "fncInputNumericValuesOnly('')"/>
Or add any other ascii code as keyCode to allow like:
8=backspace
190=dot
37=left arrow
39=right arrow
16=shift
{
if(!(event.keyCode==45||event.keyCode==46||event.keyCode==48||event.keyCode==49||event.keyCode==50||event.keyCode==51||event.keyCode==52||event.keyCode==53||event.keyCode==54||event.keyCode==55||event.keyCode==56||event.keyCode==57))
{
event.returnValue=false;
}
}
< asp:TextBox id="txtQty" runat="server" onkeypress= "fncInputNumericValuesOnly('')"/>
Or add any other ascii code as keyCode to allow like:
8=backspace
190=dot
37=left arrow
39=right arrow
16=shift
Friday, March 13, 2009
get data from .txt file and insert into sql table.
protected void button_click(object sender, EventArgs e)
{
DataTable dt = new DataTable();
DataColumn dc;
dc = new DataColumn("ACCOUNT", typeof(System.String));
dt.Columns.Add(dc);
dc = new DataColumn("CUSTOMER", typeof(System.String));
dt.Columns.Add(dc);
dc = new DataColumn("TRADES", typeof(System.String));
dt.Columns.Add(dc);
dc = new DataColumn("SHARES", typeof(System.String));
dt.Columns.Add(dc);
dc = new DataColumn("COMMISSION", typeof(System.String));
dt.Columns.Add(dc);
dc = new DataColumn("TRADES1", typeof(System.String));
dt.Columns.Add(dc);
dc = new DataColumn("SHARES1", typeof(System.String));
dt.Columns.Add(dc);
dc = new DataColumn("COMMISSION1", typeof(System.String));
dt.Columns.Add(dc);
string con = "Data Source=SERVERNAME;Database=DATABASENAME;Persist Security Info=True;User ID=USERNAME;Password=PWD";
SqlConnection myConnection = new SqlConnection(con);
const string strSQL = "select * from praveen";
SqlCommand myCommand = new SqlCommand(strSQL, myConnection);
SqlDataAdapter myAdapter = new SqlDataAdapter(myCommand);
SqlCommandBuilder cb = new SqlCommandBuilder(myAdapter);
myConnection.Open();
System.IO.StreamReader sr = new System.IO.StreamReader(@"C:/Documents and Settings/nitin.dhiman/Desktop/NYSE_MERGE_ORDER_LOG.doc");
string line;
int i = 0;
while (sr.Peek() != -1)
{
i++;
line = sr.ReadLine();
if (line.Contains("MTD TRADES"))
{
flage = 1;
}
if (line.Contains("/PAGE"))
{
flage = 0;
}
if (line.Contains("TOTALS"))
{
flage = 0;
}
if (flage == 1)
{
if (line == "" || line == " " || line == " ACCOUNT CUSTOMER TRADES SHARES COMMISSION TRADES SHARES COMMISSION " || line == "---------- ------------------------------ ---------- --------------- --------------- --------- --------------- --------------- " || line == " ---------- MTD TRADES ---------- ---------- MTD SETTLES ---------- ")
{
}
else
{
string value = line;
value = value.Replace(" ", "~");
value = value.Replace("~~~~~~~~~", "~");
value = value.Replace("~~~~~~~~", "~");
value = value.Replace("~~~~~~~", "~");
value = value.Replace("~~~~~~", "~");
value = value.Replace("~~~~~", "~");
value = value.Replace("~~~~", "~");
value = value.Replace("~~~", "~");
value = value.Replace("~~", "~");
string[] text = value.Split('~');
DataRow dr = dt.NewRow();
dr[0] = text[0];
dr[1] = text[1];
dr[2] = text[2];
dr[3] = text[3];
dr[4] = text[4];
dr[5] = text[5];
dr[6] = text[6];
dr[7] = text[7];
dt.Rows.Add(dr);
myAdapter.Update(dt);
dt.AcceptChanges();
}
}
}
Response.Write(i);
}
{
DataTable dt = new DataTable();
DataColumn dc;
dc = new DataColumn("ACCOUNT", typeof(System.String));
dt.Columns.Add(dc);
dc = new DataColumn("CUSTOMER", typeof(System.String));
dt.Columns.Add(dc);
dc = new DataColumn("TRADES", typeof(System.String));
dt.Columns.Add(dc);
dc = new DataColumn("SHARES", typeof(System.String));
dt.Columns.Add(dc);
dc = new DataColumn("COMMISSION", typeof(System.String));
dt.Columns.Add(dc);
dc = new DataColumn("TRADES1", typeof(System.String));
dt.Columns.Add(dc);
dc = new DataColumn("SHARES1", typeof(System.String));
dt.Columns.Add(dc);
dc = new DataColumn("COMMISSION1", typeof(System.String));
dt.Columns.Add(dc);
string con = "Data Source=SERVERNAME;Database=DATABASENAME;Persist Security Info=True;User ID=USERNAME;Password=PWD";
SqlConnection myConnection = new SqlConnection(con);
const string strSQL = "select * from praveen";
SqlCommand myCommand = new SqlCommand(strSQL, myConnection);
SqlDataAdapter myAdapter = new SqlDataAdapter(myCommand);
SqlCommandBuilder cb = new SqlCommandBuilder(myAdapter);
myConnection.Open();
System.IO.StreamReader sr = new System.IO.StreamReader(@"C:/Documents and Settings/nitin.dhiman/Desktop/NYSE_MERGE_ORDER_LOG.doc");
string line;
int i = 0;
while (sr.Peek() != -1)
{
i++;
line = sr.ReadLine();
if (line.Contains("MTD TRADES"))
{
flage = 1;
}
if (line.Contains("/PAGE"))
{
flage = 0;
}
if (line.Contains("TOTALS"))
{
flage = 0;
}
if (flage == 1)
{
if (line == "" || line == " " || line == " ACCOUNT CUSTOMER TRADES SHARES COMMISSION TRADES SHARES COMMISSION " || line == "---------- ------------------------------ ---------- --------------- --------------- --------- --------------- --------------- " || line == " ---------- MTD TRADES ---------- ---------- MTD SETTLES ---------- ")
{
}
else
{
string value = line;
value = value.Replace(" ", "~");
value = value.Replace("~~~~~~~~~", "~");
value = value.Replace("~~~~~~~~", "~");
value = value.Replace("~~~~~~~", "~");
value = value.Replace("~~~~~~", "~");
value = value.Replace("~~~~~", "~");
value = value.Replace("~~~~", "~");
value = value.Replace("~~~", "~");
value = value.Replace("~~", "~");
string[] text = value.Split('~');
DataRow dr = dt.NewRow();
dr[0] = text[0];
dr[1] = text[1];
dr[2] = text[2];
dr[3] = text[3];
dr[4] = text[4];
dr[5] = text[5];
dr[6] = text[6];
dr[7] = text[7];
dt.Rows.Add(dr);
myAdapter.Update(dt);
dt.AcceptChanges();
}
}
}
Response.Write(i);
}
get data from xml file.
call following function:
public void abc()
{
StreamReader stream1 = new StreamReader("C:\\Inetpub\\wwwroot\\PR\\TreeNormal\\books.xml");
XmlTextReader reader = null;
reader = new XmlTextReader(stream1);
while (reader.Read())
{
// Do some work here on the data.
switch (reader.NodeType)
{
case XmlNodeType.Element: // The node is an Element.
Response.Write("<" + reader.Name);
Response.Write(">
");
break;
case XmlNodeType.Text: //Display the text in each element.
Response.Write("
" + reader.Value);
break;
case XmlNodeType.EndElement: //Display end of element.
Response.Write("" + reader.Name);
Response.Write(">
");
break;
}
//Response.Write(reader.Name + " ");
}
while (reader.Read())
{
// Do some work here on the data.
//Console.WriteLine(reader.Name);
Response.Write(reader.Name);
}
}
public void abc()
{
StreamReader stream1 = new StreamReader("C:\\Inetpub\\wwwroot\\PR\\TreeNormal\\books.xml");
XmlTextReader reader = null;
reader = new XmlTextReader(stream1);
while (reader.Read())
{
// Do some work here on the data.
switch (reader.NodeType)
{
case XmlNodeType.Element: // The node is an Element.
Response.Write("<" + reader.Name);
Response.Write(">
");
break;
case XmlNodeType.Text: //Display the text in each element.
Response.Write("
" + reader.Value);
break;
case XmlNodeType.EndElement: //Display end of element.
Response.Write("" + reader.Name);
Response.Write(">
");
break;
}
//Response.Write(reader.Name + " ");
}
while (reader.Read())
{
// Do some work here on the data.
//Console.WriteLine(reader.Name);
Response.Write(reader.Name);
}
}
Bind TreeView to sql database.
Call the following function in page_load event:
void fill_Tree()
{
//Database db = DatabaseFactory.CreateDatabase("ConStr");
//string sqlCommandName = "Select * from ParentTable";
//DbCommand dbCmd = db.GetSqlStringCommand(sqlCommandName);
//SqlDataReader Sdr = dbCmd.ExecuteReader();
/ SqlCon = new SqlConnection("Data Source=DATABASENAME;Initial Catalog=GKTraining;Persist Security Info=True;User ID=USERID;Password=gK@t#a!n!^T)");
SqlCon.Open();
/*
* Query the database
*/
SqlCommand SqlCmd = new SqlCommand("Select * from a_tbl_parent", SqlCon);
/*
*Define and Populate the SQL DataReader
*/
SqlDataReader Sdr = SqlCmd.ExecuteReader();
/*
* Dispose the SQL Command to release resources
*/
SqlCmd.Dispose();
/*
* Initialize the string ParentNode.
* We are going to populate this string array with our ParentTable Records
* and then we will use this string array to populate our TreeView1 Control with parent records
*/
string[,] ParentNode = new string[100, 2];
/*
* Initialize an int variable from string array index
*/
int count = 0;
/*
* Now populate the string array using our SQL Datareader Sdr.
* Please Correct Code Formatting if you are pasting this code in your application.
*/
while (Sdr.Read())
{
ParentNode[count, 0] = Sdr.GetValue(Sdr.GetOrdinal("ParentID")).ToString();
ParentNode[count++, 1] = Sdr.GetValue(Sdr.GetOrdinal("ParentName")).ToString();
}
/*
* Close the SQL datareader to release resources
*/
Sdr.Close();
/*
* Now once the array is filled with [Parentid,ParentName]
* start a loop to find its child module.
* We will use the same [count] variable to loop through ChildTable
* to find out the number of child associated with ParentTable.
*/
for (int loop = 0; loop < count; loop++)
{
/*
* First create a TreeView1 node with ParentName and than
* add ChildName to that node
*/
TreeNode root = new TreeNode();
root.Text = ParentNode[loop, 1];
root.Target = "_blank";
/*
* Give the url of your page
*/
root.NavigateUrl = "mypage.aspx";
/*
* Now that we have [ParentId] in our array we can find out child modules
* Please Correct Code Formatting if you are pasting this code in your application.
*/
SqlCommand Module_SqlCmd = new SqlCommand("Select * from a_tbl_child where ParentId =" + ParentNode[loop, 0], SqlCon);
SqlDataReader Module_Sdr = Module_SqlCmd.ExecuteReader();
while (Module_Sdr.Read())
{
// Add children module to the root node
TreeNode child = new TreeNode();
child.Text = Module_Sdr.GetValue(Module_Sdr.GetOrdinal("ChildName")).ToString();
child.Target = "_blank";
//child.NavigateUrl = "your_page_Url.aspx";
child.NavigateUrl = Module_Sdr.GetValue(Module_Sdr.GetOrdinal("ChildName")).ToString()+".aspx";
root.ChildNodes.Add(child);
}
Module_Sdr.Close();
// Add root node to TreeView
TreeView1.Nodes.Add(root);
}
/*
* By Default, when you populate TreeView Control programmatically, it expends all nodes.
*/
TreeView1.CollapseAll();
SqlCon.Close();
}
void fill_Tree()
{
//Database db = DatabaseFactory.CreateDatabase("ConStr");
//string sqlCommandName = "Select * from ParentTable";
//DbCommand dbCmd = db.GetSqlStringCommand(sqlCommandName);
//SqlDataReader Sdr = dbCmd.ExecuteReader();
/ SqlCon = new SqlConnection("Data Source=DATABASENAME;Initial Catalog=GKTraining;Persist Security Info=True;User ID=USERID;Password=gK@t#a!n!^T)");
SqlCon.Open();
/*
* Query the database
*/
SqlCommand SqlCmd = new SqlCommand("Select * from a_tbl_parent", SqlCon);
/*
*Define and Populate the SQL DataReader
*/
SqlDataReader Sdr = SqlCmd.ExecuteReader();
/*
* Dispose the SQL Command to release resources
*/
SqlCmd.Dispose();
/*
* Initialize the string ParentNode.
* We are going to populate this string array with our ParentTable Records
* and then we will use this string array to populate our TreeView1 Control with parent records
*/
string[,] ParentNode = new string[100, 2];
/*
* Initialize an int variable from string array index
*/
int count = 0;
/*
* Now populate the string array using our SQL Datareader Sdr.
* Please Correct Code Formatting if you are pasting this code in your application.
*/
while (Sdr.Read())
{
ParentNode[count, 0] = Sdr.GetValue(Sdr.GetOrdinal("ParentID")).ToString();
ParentNode[count++, 1] = Sdr.GetValue(Sdr.GetOrdinal("ParentName")).ToString();
}
/*
* Close the SQL datareader to release resources
*/
Sdr.Close();
/*
* Now once the array is filled with [Parentid,ParentName]
* start a loop to find its child module.
* We will use the same [count] variable to loop through ChildTable
* to find out the number of child associated with ParentTable.
*/
for (int loop = 0; loop < count; loop++)
{
/*
* First create a TreeView1 node with ParentName and than
* add ChildName to that node
*/
TreeNode root = new TreeNode();
root.Text = ParentNode[loop, 1];
root.Target = "_blank";
/*
* Give the url of your page
*/
root.NavigateUrl = "mypage.aspx";
/*
* Now that we have [ParentId] in our array we can find out child modules
* Please Correct Code Formatting if you are pasting this code in your application.
*/
SqlCommand Module_SqlCmd = new SqlCommand("Select * from a_tbl_child where ParentId =" + ParentNode[loop, 0], SqlCon);
SqlDataReader Module_Sdr = Module_SqlCmd.ExecuteReader();
while (Module_Sdr.Read())
{
// Add children module to the root node
TreeNode child = new TreeNode();
child.Text = Module_Sdr.GetValue(Module_Sdr.GetOrdinal("ChildName")).ToString();
child.Target = "_blank";
//child.NavigateUrl = "your_page_Url.aspx";
child.NavigateUrl = Module_Sdr.GetValue(Module_Sdr.GetOrdinal("ChildName")).ToString()+".aspx";
root.ChildNodes.Add(child);
}
Module_Sdr.Close();
// Add root node to TreeView
TreeView1.Nodes.Add(root);
}
/*
* By Default, when you populate TreeView Control programmatically, it expends all nodes.
*/
TreeView1.CollapseAll();
SqlCon.Close();
}
Subscribe to:
Posts (Atom)