Search This Blog

Wednesday, November 20, 2013

Read - Write Binary to File Stream

C# > Files > Read - Write Binary

BinaryWriter : writes primitive types in binary to a stream.
BinaryReader: reads primitive data types as binary.

Example:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            const string fileName = "C:\\Settings.dat";
            using (BinaryWriter writer = new BinaryWriter(File.Open(fileName, FileMode.Create)))
            {
                writer.Write("Verdana"); // font name
                writer.Write(10);        // font size
                writer.Write(true);      // font bold
            }
            string fontFname;
            int fontSize;
            bool fontBold;

            using (BinaryReader reader = new BinaryReader(File.Open(fileName, FileMode.Open)))
            {
                fontFname = reader.ReadString();
                fontSize = reader.ReadInt32();
                fontBold = reader.ReadBoolean();
            }
         }
    }
}

 






DllImport Attribute C# Example

C# > InteropServices > DllImport

DllImport Attribute  marks a class method defined in an external dynamic-link library (DLL) not in  .NET assembly.

DllImport attribute is used at run time to call a function exported in an external DLL  outside the control of common language runtime (CLR).


DllImport is helpful when accessing and reusing the functionality of the Win32 application programming interface (API) and  unmanaged codes that are implemented in DLL.

Example:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        [DllImport("User32.dll")]
        public static extern int MessageBox(int h, string m, string c, int type);

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            MessageBox(0, "This is an example of using DLLImport to call a Win32 function", "User32 MessageBox", 0);
        }
    }
}

 




Tuesday, November 19, 2013

Get list of all tables in Oracle

Oracle >List of all tables

See all the tables that your account has access


SELECT owner, table_name FROM all_tables

See table that you own


SELECT table_name FROM user_tables





Oracle Connection strings

Oracle > Connection strings


With tnsnames.ora

Data Source=OracleDB;User Id=Username;Password=Password;
Integrated Security
=no;

Without tnsnames.ora

Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=yourHost)(PORT=yourPort))(CONNECT_DATA=(SERVICE_NAME=yourOracleSID)));
User Id=Username;Password=Password;





Monday, November 18, 2013

BLOB (Binary Large Object) Oracle Data Type

Oracle > Data Type > BLOB

A BLOB (Binary Large Object) can hold up to 4 GB of data. BLOB's are designed for storing digitized information like images, audio, video.

Example:

CREATE TABLE blob_table (id NUMBER, doc BLOB);
INSERT INTO blob_table VALUES (1, EMPTY_BLOB());

select * from blob_table




Thursday, November 14, 2013

HyperText Markup Language (HTML)

HyperText Markup Language (HTML) is markup language used for creating web pages and other data that can be displayed in a web browser.




Fix div at the bottom of the page

HTML > DIV > Fix at the bottom of the page





<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
</head>
<body>
    Content
    <div style="position: fixed; bottom: 0px;">
        This is div fixed at the bottom of the page</div>
</body>
</html>