Search This Blog

Wednesday, November 20, 2013

How to get SQL Server authentication logins

SQL Server > System Views > Catalog > sys.sql_logins

sys.sql_logins returns information about SQL Server authentication logins.

Example:

SELECT m.name, m.principal_id, m.type_desc, m.password_hash FROM master.sys.sql_logins m

Result:

name principal_id type_desc password_hash
sa 1 SQL_LOGIN 0x0200D225062FC1F5301DB7D08706A19C5CC900AB979B59D33B8ACB61F5

D5FCCF9BA0CE660B47435B9A5BD1F06D63C56A4DC6FB69EA429978866AEE29FA440F4E3D
4AE336D3D2





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.