Tuesday, September 19

Maintain aspect ratio on image tag

Sometimes we are using img tag instead of background-image when displaying images to our page, specially when we have dynamic content to display. To  Maintain aspect ratio using background we normally do or declare:
 
div {
  background: url({url});
  width: 200px;
  height: 200px;
  background-size: cover;
}

But if you are using img tag, you may use
  object-fit: cover;


Example:
img {
  width: 200px;
  height: 200px;
  object-fit: cover;
}



To God all the Glory

Tuesday, March 11

Exporting data table in Oracle database.


This tutorial is one way of exporting our data table in Oracle database.
This is for Windows XP Operating System. First create a Folder in My Documents,
this folder is where we save the table file (.dmp).
Make sure you created the folder in My Documents. Then open word editor
and type following syntax or script:

ECHO ON
SET ORACLE_SID= DatabaseName
EXP USERNAME/PASSWORD TABLES='TableName' file=FolderYouCreated\NameOfTable.dmp


Then save the file with .bat (export.bat). Make sure that you also save it in My Documents.
Once done double click the .bat file.


For more than one tables the syntax is:

ECHO ON
SET ORACLE_SID= DatabaseName
EXP USERNAME/PASSWORD TABLES='TableName1' file=FolderYouCreated\NameOfTable1.dmp
EXP USERNAME/PASSWORD TABLES='TableName2' file=FolderYouCreated\NameOfTable2.dmp
EXP USERNAME/PASSWORD TABLES='TableName3' file=FolderYouCreated\NameOfTable3.dmp


In some point we dont want others to see our database log-in parameters, we can use the
syntax below:


ECHO ON
SET ORACLE_SID= DatabaseName
EXP  TABLES='TableName1' file=FolderYouCreated\NameOfTable1.dmp
EXP  TABLES='TableName2' file=FolderYouCreated\NameOfTable2.dmp
EXP  TABLES='TableName3' file=FolderYouCreated\NameOfTable3.dmp




this systax will promp you to enter you username and password. Once we exported the tables
we need to import it. The following syntax is for importing the exported tables:

ECHO ON
SET ORACLE_SID= DatabaseName
IMP USERNAME/PASSWORD TABLES='TableName1' file=FolderYouCreated\NameOfTable1.dmp
IMP USERNAME/PASSWORD TABLES='TableName2' file=FolderYouCreated\NameOfTable2.dmp
IMP USERNAME/PASSWORD TABLES='TableName3' file=FolderYouCreated\NameOfTable3.dmp


We just simply change the EXP to IMP, then save it again with .bat (import.bat) once save
double click the file and  check it to your database. Thats it I hope it helped you!
Thank you for reading and God bless you!




22 Because of the Lord’s great love we are not consumed,  for his compassions never fail.
23 They are new every morning; great is your faithfulness.
24 I say to myself, “The Lord is my portion;
    therefore I will wait for him.”

Lamentation 3:22-24




To GOD all the Glory.

Monday, December 16

Populate data to Combobox Control

Combobox control let us select an item to the list of items (msdn.microsft/Combobox). Combobox items are sometimes static items and sometimes requires to be binded to database, there are many ways to do it, and one of those using the code below: 

 1. On the Form and Combobox control and name it anything you like 
 2. On Form_Load event and the code below:


Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
    'Specify the datasource
    Dim CONNECTION_STRING As String = "Data Source=LOCALHOST;Initial Catalog=DB_NAME; Integrated Security=True"

    Dim conn As SqlConnection = New SqlConnection(CONNECTION_STRING)
    'Specify the SELECT query
    Dim cmd As SqlCommand = New SqlCommand("SELECT ProductName FROM ProductTable", conn)



    'Open the Database
    conn.Open()

    Dim sdr As SqlDataReader = cmd.ExecuteReader

    'Do the adding through looping
    While sdr.Read()
        If Not sdr("ProductName").ToString = String.Empty Then product.Items.Add(sdr.Item("ProductName").ToString)

    End While

    'Close the Database

    conn.Close()

End Sub