Tuesday, May 31, 2011

How to insert audio file into SQL Server and retrieve it back and play it?


This is how the form looks like.








This is the source code,
This is the code for inserting audio file into sql server,
            SqlConnection con = new SqlConnection("ConnectionString");
            SqlCommand com = new SqlCommand("insert into tblVoice(FileName, FilePath, fldvoice) values(@Filename,@FilePath,@voice)", con);
            OpenFileDialog fileDialog = new OpenFileDialog();
            fileDialog.ShowDialog();

            byte[] stream = File.ReadAllBytes(fileDialog.FileName);
            if (stream.Length > 0)
            {
                com.Parameters.AddWithValue("@Filename", fileDialog.SafeFileName);
                com.Parameters.AddWithValue("@FilePath", fileDialog.FileName);
                com.Parameters.AddWithValue("@voice", stream);
                con.Open();
                int result = com.ExecuteNonQuery();
                if (result > 0)
                    MessageBox.Show("insert done");
                con.Close();
            }
This is the code for retrieving the audio file from sql server,
            SqlConnection con = new SqlConnection("ConnectionString");
            SqlCommand com = new SqlCommand("select * from tblVoice", con);
            con.Open();
            DataTable dt = new DataTable();
            SqlDataReader dr = com.ExecuteReader();
            OpenFileDialog fileDialog = new OpenFileDialog();
            fileDialog.ShowDialog();
            dt.Load(dr);
            dr.Close();
            con.Close();
            byte[] stream = null;
            string path = @"C:\SynRISTempFiles\";
            string name = string.Empty;
            foreach (DataRow rw in dt.Rows)
            {
                if (Convert.ToString(rw[0]) == fileDialog.SafeFileName)
                {
                    stream = (byte[])rw[2];
                    name = (string)rw[0];
                }
            }
            File.WriteAllBytes(path + name, stream);
            axWindowsMediaPlayer1.URL = path + name;

References that I used:
http://www.codeproject.com/KB/audio-video/Concatenation_Wave_Files.aspx

How to determine which form is open?

You wish to determine which form is open. Here is the code that will determine whether the form is open or not.
                    PDFViewer viewer = null;
                    foreach (Form OpenForm in Application.OpenForms)
                    {
                        if (OpenForm.GetType() == typeof(PDFViewer))
                        {
                            viewer = (PDFViewer)OpenForm;
                        }
                    }
                    viewer.CloseForm();

Sunday, May 15, 2011

Silverlight 4 Book Details and Links

If you are looking for books in silverlight 4 that is posted on these site,
http://www.silverlight.net/learn/
except for Microsoft Silverlight 4 Step By Step By Laurence Moroney

Microsoft Silverlight 4 Step By Step By Laurence Moroney
http://oreilly.com/catalog/9780735638860

Silverlight 4 in Action By Pete Brown
http://www.manning.com/pbrown/

Silverlight 4 Unleashed by Laurent Bugnion
http://www.amazon.com/Silverlight-4-Unleashed-Laurent-Bugnion/dp/0672333368
http://www.pearson.ch/Informatik/SamsPublishing/1471/9780672333361/Silverlight-4-Unleashed.aspx

Professional Silverlight 4 by Jason Beres, Bill Evjen, Devin Rader
http://www.wrox.com/WileyCDA/WroxTitle/Professional-Silverlight-4.productCd-0470650923,descCd-tableOfContents.html

Microsoft Silverlight 4 and Sharepoint 2010 Integration by Gaston C Hillar
http://www.packtpub.com/microsoft-silverlight-4-and-sharepoint-2010-integration/book

Silverlight 4 Jumpstart by David Yack
http://www.silverlightjumpstart.com/

You may view these books online thru this site,
http://my.safaribooksonline.com/

Wednesday, May 11, 2011

MS SQL Server 2005 SP3

Overview
--------------------------------------------------------------------------------
Service Pack 3 for Microsoft SQL Server 2005 is now available. SQL Server 2005 service packs are cumulative, and this service pack upgrades all service levels of SQL Server 2005 to SP3. You can use these packages to upgrade any of the following SQL Server 2005 editions:
•Enterprise
•Enterprise Evaluation
•Developer
•Standard
•Workgroup
Note: To upgrade SQL Server 2005 Express Edition, obtain the SP3 version of Express Edition or Express Edition with Advanced Services.
For a list of new features and improvements that are included in SQL Server 2005 SP3, review the What's New document.
Top of pageSystem Requirements
--------------------------------------------------------------------------------
•Supported Operating Systems:Windows 2000 Service Pack 4;Windows 7;Windows Server 2003;Windows Server 2008;Windows Server 2008 R2;Windows Vista;Windows XP
•32-bit systems (x86)
◦PC with Intel or compatible Pentium III 600 MHz or higher processor (1 GHz or faster recommended)
•64-bit systems (x64, ia64)
◦1GHz or faster processor
•Minimum of 512 MB of RAM (1 GB or more recommended)
•675 MB of available hard disk space
Note: SQL Server 2005 Service Pack 3 (SP3) is designed to run on Windows Vista and Windows Server 2008. For more information about installing and running SQL Server 2005 on Windows Vista and Windows Server 2008, see this Microsoft Web site.
Top of pageInstructions
--------------------------------------------------------------------------------
Note: You must have administrative rights on the computer to install SQL Server 2005 SP3.

Step 1: Download and review the setup documentation and readme file. For known issues, review the release notes.
Step 2: Download the appropriate package by clicking one of the links below. To start the installation immediately, click Run. To install SP3 at a later time, click Save.

If you wish to download the SP3 for SQL Server 2005. Here is the link,
http://www.microsoft.com/downloads/en/details.aspx?FamilyID=ae7387c3-348c-4faa-8ae5-949fdfbe59c4

Silverlight 4 Resources

Silverlight 4 Tools, Samples, Documents, Hands-On Labs, Books, Whitepapers
http://www.silverlight.net/getstarted/

Microsoft Expression Blend Software Development Kit (SDK) for Silverlight 4
http://www.microsoft.com/downloads/en/details.aspx?FamilyID=D197F51A-DE07-4EDF-9CBA-1F1B4A22110D&displaylang=en

Silverlight 4 Toolkit
http://silverlight.codeplex.com/releases/view/43528

Silverlight 4 Samples
http://silverlight.net/content/samples/sl4/toolkitcontrolsamples/run/default.html

Silverlight for Windows Phone Toolkit - Feb 2011
http://silverlight.codeplex.com/releases/view/60291

Deeveloper Tools For Windows Phone and XBOX 360
http://create.msdn.com/en-us/home/getting_started
http://create.msdn.com/en-US/

Microsoft Expression Blend 4 + SketchFlow
http://expression.microsoft.com/en-us/cc136530.aspx

Download Trial Version Of Microsoft Expression
http://www.microsoft.com/expression/try-it/Default.aspx#PageTop

WCF RIA Services
http://www.silverlight.net/getstarted/riaservices/
http://www.microsoft.com/downloads/en/details.aspx?FamilyID=6f834bf7-ffde-4d5d-8573-18541762118b&displaylang=en

Tuesday, May 10, 2011

How to disable back button of browser and not delete the history?

To disable back button of browser ... delete history
Put this javascript at the <head> tag
    <script type="text/javascript">
        function setFocus()
        {
            document.getElementById("contentPage").focus();
            var URL;
            var i;
            var QryStrValue;
            URL = window.location.href;
            i = URL.indexOf("?");
            QryStrValue = URL.substring(i + 1);
            if (QryStrValue != 'X')
            {
                window.location = URL + "?X";
            }
        }
     </Script>
Then call your function using onload event in <body> tag.
<body onload="setFocus()">
Here is the reference that I use:
http://www.daniweb.com/web-development/javascript-dhtml-ajax/threads/60682

Set focus on your content page upon loading

If you want to set focus on the content page, put your javascript on <head> tag, then call the function using onload event on the body. Then create an id on the part that you wish to set focus.

<head runat="server">
    <title></title>
    <asp:ContentPlaceHolder ID="head" runat="server">
    </asp:ContentPlaceHolder>
    <link href="Template.css" rel="stylesheet" type="text/css" />
    <link href="Main_Menu.css" rel="stylesheet" type="text/css" />
    <link type="text/css" href="css/ui-lightness/jquery-ui-1.8.12.custom.css" rel="stylesheet" />
    <style type="text/css">
</head>
...
<body onload="setFocus()">
    <form id="form1" runat="server">
...
                                            <table border="0" cellpadding="0" cellspacing="0" width="100%" class="canvas">
                                                <tr>
                                                    <td valign="top" id="contentPage">
Javascript focus method
http://www.bloggingdeveloper.com/post/Setting-Focus-Using-Javascript-to-an-Input-Field-(Textbox)-when-the-Page-Loads.aspx
http://forums.htmlhelp.com/index.php?showtopic=5399
http://www.roseindia.net/javascript/javascript-focus-method.shtml

Tuesday, May 3, 2011

Comparison Between Microsoft SQL Server 2005 and 2008

You may refer to these links below for comparison between the two,
MS SQL Server 2008
http://msdn.microsoft.com/en-us/library/ms143432.aspx
http://www.microsoft.com/sqlserver/2008/en/us/default.aspx
http://www.microsoft.com/sqlserver/2008/en/us/express.aspx
http://www.microsoft.com/sqlserver/2008/en/us/compare-std-ent.aspx
http://www.microsoft.com/sqlserver/2008/en/us/compare-specialized.aspx
MS SQL Server 2005
http://msdn.microsoft.com/en-us/library/ms143432(v=SQL.90).aspx
http://www.microsoft.com/sqlserver/2005/en/us/compare-features.aspx

What are the key differences between MS SQL Server 2005 and 2008?
  • Transparent Data Encryption. The ability to encrypt an entire database.
  • Backup Encryption. Executed at backup time to prevent tampering.
  • External Key Management. Storing Keys separate from the data.
  • Auditing. Monitoring of data access.
  • Data Compression. Fact Table size reduction and improved performance.
  • Resource Governor. Restrict users or groups from consuming high levels or resources.
  • Hot Plug CPU. Add CPUs on the fly.
  • Performance Studio. Collection of performance monitoring tools.
  • Installation improvements. Disk images and service pack uninstall options.
  • Dynamic Development. New ADO and Visual Studio options as well as Dot Net 3.
  • Entity Data Services. Line Of Business (LOB) framework and Entity Query Language (eSQL)
  • LINQ. Development query language for access multiple types of data such as SQL and XML.
  • Data Synchronizing. Development of frequently disconnected applications.
  • Large UDT. No size restriction on UDT.
  • Dates and Times. New data types: Date, Time, Date Time Offset.
  • File Stream. New data type VarBinary(Max) FileStream for managing binary data.
  • Table Value Parameters. The ability to pass an entire table to a stored procedure.
  • Spatial Data. Data type for storing Latitude, Longitude, and GPS entries.
  • Full Text Search. Native Indexes, thesaurus as metadata, and backup ability.
  • SQL Server Integration Service. Improved multiprocessor support and faster lookups.
  • MERGE. TSQL command combining Insert, Update, and Delete.
  • SQL Server Analysis Server. Stack improvements, faster block computations.
  • SQL Server Reporting Server. Improved memory management and better rendering.
  • Microsoft Office 2007. Use OFFICE as an SSRS template. SSRS to WORD.
  • SQL 200 Support Ends. Mainstream Support for SQL 2000 is coming to an end.
Other References:
http://stackoverflow.com/questions/198478/advantages-of-ms-sql-server-2008-over-ms-sql-server-2005
http://www.postgresonline.com/journal/archives/51-Cross-Compare-of-SQL-Server,-MySQL,-and-PostgreSQL.html
http://en.wikipedia.org/wiki/Microsoft_SQL_Server
http://oracleappstechnology.blogspot.com/2008/06/oracle-11g-vs-microsoft-sql-server-2008.html
http://decipherinfosys.wordpress.com/2008/09/28/differences-between-different-sql-server-2008-editions/