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



Wednesday, December 7

Disable editing in combobox control in VB.Net

This is a very simple tutorial yet it's very helpful. We use combobox to dispaly an editable list of text/string but what if we do not want or allow our user to edit the items in a combobox? what we want is to select from list of choices. This codes will disallowing our user to modify or edit the text/string in our combobox control.

First drop a combobox control in the form and name it. Go to the code and declare a boolean variable and set it to false:




Public Class Form1
Dim editingInCombobox As Boolean = False


then create keypress event in the combobox control (creating event in vbnet code window).



Once you done, add the following line of codes in the keypress block:


If Not editingInCombobox Then e.Handled = True

Beep()



editingInCombobox = is the boolean variable we declared
Beep ( ) = Sounds a tone through the computer's speaker.

That's it, I hope you like it.



15 That ye may be blameless and harmless, the sons of God, without rebuke, in the midst of a crooked and perverse nation, among whom ye shine as lights in the world;


Philipians 2:15 KJV


Praise to LORD JESUS CHRIST


Creating event in VB.Net Code window

Basically, we create an event by double clicking the control or write it manually, this is what we always do. This post is one way to create an event is our controls.

STEPS:
Drop the control to the designer then rename the control (renaming control is a good practice when we do programming).
This example is using button control

 After we created and renamed the control go to the code window and select the control (btnEvent) from the class name

 

Then select the event or method in the Method name list. The list contains all of the posible event you can use in a control

That's it, type the codes and do the logic inside the block. I hope it helped you.


The LORD is my rock, and my fortress, and my deliverer; my God, my strength, in whom I will trust; my buckler, and the horn of my salvation, and my high tower. I will call upon the LORD, who is worthy to be praised: so shall I be saved from mine enemies. 

Psalm 18:2-3



Praise the LORD

Saturday, November 12

Displaying total value of a column in SQL

Im going to show how to display total value of your data in the database. This script will works on integer datatype (Im not sure if it work in currency or money datatype but Maybe it will work).

The SQL syntax is:

SELECT  ISNULL(Column1, 'TheLastWord') AS ALIAS, Column2      
FROM (
      SELECT Column1,
             GROUP_FUNCTION(Column1) AS Column1,
             GROUP_FUNCTION(Column2) AS Column2
      FROM TABLE
          GROUP BY Column1 WITH ROLLUP
     ) AS ALIAS



Example:

SELECT ISNULL(Sales_MONTHS, 'TOTAL SALES in 2011') AS MONTH
   TRANSACTION ,      
   SALES
    
FROM (
      SELECT Sales_MONTHS,
             SUM(TRANSACTION ) AS TRANSACTION ,
             SUM(SALES) AS SALES
           
      FROM SALES_TABLE
          GROUP BY Sales_MONTHS WITH ROLLUP
     ) AS BI






Note that this script or systax works in MS SQL. Other database may have different syntax.
Thats it, I hope this simple tutorial would helped.





3 Then Jesus told them this parable: 4 “Suppose one of you has a hundred sheep and loses one of them. Doesn’t he leave the ninety-nine in the open country and go after the lost sheep until he finds it? 5 And when he finds it, he joyfully puts it on his shoulders 6 and goes home. Then he calls his friends and neighbors together and says, ‘Rejoice with me; I have found my lost sheep.’ 7 I tell you that in the same way there will be more rejoicing in heaven over one sinner who repents than over ninety-nine righteous persons who do not need to repent.

Luke 15:3-7(NIV)

To God all the Glory!

Wednesday, October 19

VB.NET: Listview control (Change the row backcolor of Filtered data)

This tricks is the continuation of my previous and first article VB.NET. Well this is very useful tricks, it will allow the user to change the backcolor of the row based on the condition.


SAMPLE:

 if the job title of the customers is owner then change the row color to blue.
 (not just the row color, we can also change the font style or color of the data)





In the example, I use radion button to do the filtering, but it depends of you how or what control you will use. We can use listbox, dropdown, combobox, textbox etc. After you choose the control you want, create an event on that control,in the example the event for radio box is CheckedChanged, and then copy the codes below:



(Populate the data first)

    For i = 0 To ListViewControl.Items.Count - 1
            ListViewControl.Items(i).BackColor = Color.White
            If ListViewControl.Items(i).SubItems(4).Text = "Purchasing Manager"  Then
                ListViewControl.Items(i).BackColor = Drawing.Color.Red
            End If
    Next i


I try to explain the codes;

1st:  first we use for loop to move to the next index,
2nd:    next we make the listview backcolor to anycolor we want, I use white for this.
3rd:      After that we do the checking;
                  Example:
             if the text of listview subitem(column index) is equal to "Owner"/"Puchasing Manager" then
4th:     change its backcolor to Red (or any color you want)
5th:   end the If statement
6th:  then move to the next i or index



Other example:

Job title is Purchasing Manager
  
   
Job title is Purchasing Representative

Like we know, not just the backcolor that we can change, we can also change font size, style and color.

Thank you reading, I hope you understand the logic.
 Hope you like it.





For I know the plans I have for you," declares the LORD, "plans to prosper you and not to harm you,
plans to give you hope and a future.

Jeremiah 29:11

To GOD all the GLORY




Monday, October 17

VB.NET: Listview control (Backcolor and Alternate row color)

This is my first article for VB.NET. This techniques will help our user to see data clearly and more presentable.

ListView control allows you to display a list of items with item text and, optionally, an icon to identify the type of item. The ListView control can be used to display information from an application, a database, or a text file. It provides a large number of properties that provide flexibility in appearance and behavior(http://social.msdn.microsoft.com/Search/en-us?query=listview&x=0&y=0).



Well basically,we can change our listview background directly to the property window just select the listview then change the backColor, choose the color you want. But if you want to code it just simply add this line:





ListViewName.BackColor=Color.ColorYouWant

                                                                                                                             
If we want to have alternate rows color we can use this codes



After you populate or retrieve your data put the codes next to it to have an alternate row color. Select the color you want.




Output:



I hope you understand it and helped you!




"'Love the Lord your God with all your heart and with all your soul and with all your strength and with all your mind'; and, 'Love your neighbor as yourself.'"

Luke 10:27


To GOD all the Glory