Skip to main content

Posts

C Sharp User Define SQL Database Class

This is the simple user define SQL Database Class. It is useful to avoid redundancy of the code. Database Class In C# using System; using System.Data; using System.Data.SqlClient; using System.Configuration; public class _Database { public SqlConnection con; public SqlCommand com = null; public SqlDataReader dr = null; public SqlDataAdapter da = null; public DataSet ds = null; public String glQuery = ""; public String glnonQuery = ""; public const int EXECUTE_NONE_QUERY = 1; public const int EXECUTE_QUERY = 2; public const int DATA_ADAPTER = 3; // connection for data list paging public SqlConnection globalcon = new SqlConnection("server=**;uid=**;pwd=***;Database=**"); public _Database() { } public void Query(String SqlQuery) { this.glQuery = this.Get_DataBasePrefix(SqlQuery); } private String Get_DataBasePrefix(String str) { return str.Replace("#__", "GD_").ToString(); } public void ConnectDB() { try { con = new SqlConnection(); con.Co

FTP File Uploading Using C Sharp

This is the example to upload file using FTP Web Request. using system.net; using system.io; FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create("ftp://myDoc.com/xyz.pdf"); / request.Method = WebRequestMethods.Ftp.UploadFile; request.Credentials = new NetworkCredential(username, password); request.UsePassive = true; request.UseBinary = true; request.KeepAlive = false; //Load the file FileStream stream = File.OpenRead(filePath); //c:/myDoc/xyz.pdf byte[] buffer = new byte[stream.Length]; stream.Read(buffer, 0, buffer.Length); stream.Close(); //Upload file Stream reqStream = request.GetRequestStream(); reqStream.Write(buffer, 0, buffer.Length); reqStream.Close(); btnUpload.UseWaitCursor = false;

Create XML File From Mysql Table

How to create XMLFile Form Mysql Table function createXMLFile($result, $feildLength, $dir) { $headers = array(); $xmlData = array(); $str = ""; $counter = 0; for ($i=0;$i<$feildLength;$i++) { array_push($headers, mysql_field_name($result, $i)); } $xmlFileData = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; while ($row = mysql_fetch_array($result)) { for ($i=0;$i<$feildLength;$i++) { $str .= "<".trim($headers[$i]).">" . escapeXMLEntities(trim($row[$i])) . "</".trim($headers[$i]).">\n"; $counter++; //increment column# if ($counter == $feildLength) { //new row array_push($xmlData, "<record>\n" . $str . "</record>\n"); $str = ""; $counter = 0; } } } $xmlFileData .= "<records name=\"Customer_Table\">\n" . implode("", $xmlData) . "</records&g

Creating Data Grid Using HTTP Service in Flex

Creating Data Grid Using HTTP Service in Flex & displaying data using XML in flex. <?xml version='1.0' /> <Data> <ID>1</ID> <Name>Vineet</Name> </Data> <Data> <ID>2</ID> <Name>Abhishek</Name> </Data> This Data Grid Example will display above xml data in grid. <mx:application mx="http://www.adobe.com/2006/mxml" layout="absolute" creationcomplete="init()"> <mx:httpservice id="xmlFile" url="http://localhost/***/***/project.php" result="getXML(event)" resultformat="e4x" /> <mx:script> <!--[CDATA[ import mx.rpc.events.ResultEvent; [Bindable] --> </mx:script> <mx:panel x="10" y="10" width="100%" height="100%"> <mx:canvas label="XYZ" width="100%" height="100%"> <mx:datagrid x="10" y="10" width="10

Drawing Line and arrow using flex

How to drawing line with arrow in flex? public function addPoint(sX:int,sY:int,eX:int,eY:int, createArrow:Boolean):void { var g:Graphics =this.graphics; g.lineStyle(1, 0xff0000, 1); g.moveTo(sX, sY); g.lineTo(eX, eY); if(createArrow){// drawing arrow g.lineStyle(6, 0x0000ff, 1); g.moveTo(Math.round(eX+((sX-eX)/6)), Math.round(eY+((sY-eY)/6))); // mid point g.lineTo(eX, eY); g.lineStyle(3, 0x00ff00, 1); g.moveTo(Math.round(eX+((sX-eX)/6)), Math.round(eY+((sY-eY)/6))); // mid point g.lineTo(eX, eY); } }

How to use Accordion window in Flex

<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"> <mx:Panel x="119" y="63" width="382" height="268" layout="absolute" title="Accordion select"> <mx:HBox width="100%" height="100%" id="hbox6"> <mx:Accordion width="100%" height="100%"> <mx:Canvas width="100%" label="Accordion 1"> </mx:Canvas> <mx:Canvas width="100%" label="Accordion 2"> </mx:Canvas> <mx:Canvas width="100%" label="Accordion 3"> </mx:Canvas> <mx:Canvas width="100%" label="Accordion 4"> </mx:Canvas> </mx:Accordion> </mx:HBox> </mx:Panel> </mx:Application>