WHAT'S NEW?
Loading...

Inserting record using DataSet InsertQuery in VB.NET

There’s a lot of way you can play with VB.NET in inserting record. However, programming getting easier to perform query and act on the same way like traditional query. In traditional way, we write more lines of code to accomplish what we aim for in our program. In this tutorial, I’m going to show how to insert records in vb.net using dataset insert query.

In databinding, the generated code in saving a record into database is the following.

Me.Validate()
Me.TblInformationBindingSource.EndEdit()
Me.TableAdapterAdapter.Update(Me.DBTestDataSet.tblInformation)

Unfortunately, not all the time we rely on this code. Now, I used my own query that works on the same way. In your solution explorer, double click the name of your DataSet. Right click and Add Query… on your table. Click Next INSERT query, and the following result that specify what data should the table load.

Query using DataSet VB.NET


INSERT INTO `tblInformation` (`Firstname`, `Lastname`, `Middlename`, `Gender`, `Address`, `Age`, `DateOfBirth`) VALUES (?, ?, ?, ?, ?, ?, ?)

Question marks may vary the number of specified columns.

Click Next, name your query and proceed to Finish.

Me.TblInformationTableAdapter.InsertQuery(FirstnameTextBox.Text, LastnameTextBox.Text, cbMI.Text,cbGender.Text, AddressTextBox.Text, AgeTextBox.Text, txtDateOfBirth.Text)
                        Me.TblInformationTableAdapter.Update(Me.DBTestDataSet.tblInformation)
                        MessageBox.Show("New records added to your database", "Successfully Saved", MessageBoxButtons.OK, MessageBoxIcon.Information)


That’s all! You can insert record into multiple tables.

Getting started in basic Android programming

Basic android programming
It’s more fun in programming – many people consider this kind of stuffs as their fashion way of exploring the world of technology by developing computer programs and mobile apps that runs on various platform. The latest trends is developing Apps in Android, why Android? Now a day, smartphone are widely used by many users where the powerof Android Operating System runs dependent on its hardware. To learn Android programming is not a big deal to cover all programming languages to enable you writes mobile application. However, basic knowledge in programming is advantage. Basic Android programming was based (Linux Kernel) on Java, its looks like very similar. For instance, Android runs dependent on its Software Development Kit (SDK) every time you create and run the program. To setup Android, you must download first the Android Developer Tools (ADT) bundled that includes everything you need for developing apps. This package includes the following:

·         Eclipse + ADT plugin
·         Android SDK Tools
·         Android Platform-tools
·         The latest Android platform
·         The latest Android system image for the emulator

 It’s not quite difficult to configure if you follow the steps.

Android comes in many flavors (version) to taste, and makes sweeter as many flavors to come. For developers, you must aware the target version wants to develop Apps because the version may vary the compatibility of hardware in every device. It includes the target device, if it is design for smartphone, Tablets, or TV. In addition, common issues in developing Apps are the compatibility of the said versions. It’s not like a desktop application where the hardware and screen size has minimal issue.  

My Android Apps I made will run on other smartphone devices?

Not necessary! Android will run only on its own hardware compatibility, if you have an Android Phone any Apps can install on your device. However, as what I have said, it depends on what version of Android Phone and Apps you have. If you are going to develop Apps, you must specify the minimum target version in order the other Android users not get problem during their installation. For instance, make a regular updates about your Apps by simply giving them a versions.

Android sample code in XML layout

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".AndroidBasic" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/hello_world" />

</RelativeLayout>

Android sample code

package com.test.test;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

public class AndroidBasic extends Activity {
                @Override
                protected void onCreate(Bundle savedInstanceState) {
                                super.onCreate(savedInstanceState);
                                setContentView(R.layout.activity_android_basic);
                }
                @Override
                public boolean onCreateOptionsMenu(Menu menu) {
                                // Inflate the menu; this adds items to the action bar if it is present.
                                getMenuInflater().inflate(R.menu.android_basic, menu);
                                return true;
                }
}


Keep on exploring Android Programming, many websites will teach you online regarding this matter. Hope this is very helpful in Basic understanding in Android Programming.

The power of Android Operating System

Android Operating System
Smartphones are the most widely used in our modern world as technology rises in the market, Google is one of the said top smartphone that many users uses their products in various ways. And many programmers, developers, engineer, and designer want to acquire the power of Android Operating System to design their own apps, games, or business related apps for many users. It’s an open source, means anyone has the knowledge in programming can work this kind of skills and it can develop sophisticated apps that run in many android devices. Good thing about android is that, many application on the internet are free and available to download that not have on other Smartphone like Apple or Windows, this was based on my review and those people can afford to buy some apps online. However, if you’re good in searching, you will find “crack” apps that are free, but in play store it cost dollars.

Increase your wealth in developing Apps.

You've already have a team? Not yet! If you had an idea in programming, that’s the time to increase your wealth in developing apps. Android is based on Java programming that run dependent on Android SDK,  code are very similar to Java but there some distinction both of them. Don’t worry, internet can help you out! A lot of tutorials, source code, and eBooks are available online. Now, building your network or team can reach your goal to cater the clients their need. Once you already have a team that composed of skilled programmer, developer, designer, and engineer. You can now accept clients in their needs, why I am telling you this! Most developers earn online in creating apps, especially in Android because that is open source and easy to learn (Not probably easy in some way), unlike Apple – you should have an apple device in order you to develop apps. Many jobs online are home base, communication and payment made through internet. The power of Android is now widely used in many platforms, example Google TV. In addition, expand your ideas not only for Android but in some other things where you are suited, or perhaps you enjoyed!

Encryption in VB.NET that will store in DB Access

In this tutorial, I’ll show you how to create a login system in vb.net that will encrypt password character into Microsoft Access Database. In various application today, data are very important for security, and there’s a lot of application apply this kind of encryption to ensure that all information specifically password by many users not hack by any users. This simple idea of encryption in Visual Basic.Net will give you an idea how to use it in your programming techniques. First thing you need is to create a database name [DbAccount] and tblAccount that has a column ID, Username, and Password.

To encrypt password character to save into database:

 Dim sPlainText As String = Me.txtPasswordSave.Text
        If Not String.IsNullOrEmpty(sPlainText) Then
            Dim memoryStream As MemoryStream = New MemoryStream()
            Dim cryptoStream As CryptoStream = New CryptoStream(memoryStream, Me.encryptor, CryptoStreamMode.Write)
            cryptoStream.Write(Me.enc.GetBytes(sPlainText), 0, sPlainText.Length)
            cryptoStream.FlushFinalBlock()
            Me.txtPasswordSave.Text = Convert.ToBase64String(memoryStream.ToArray())

            Me.Validate()
            Me.TblAccountBindingSource.EndEdit()
            Me.TblAccountTableAdapter.Update(Me.DbAccountDataSet.tblAccount)
            MessageBox.Show("Saved")

            memoryStream.Close()
            cryptoStream.Close()
Else
            MessageBox.Show("Please fill the textbox")
       End If

To login my username and password:

 Dim sPlainText As String = Me.txtPasswordLogin.Text
        If Not String.IsNullOrEmpty(sPlainText) Then
            Dim memoryStream As MemoryStream = New MemoryStream()
            Dim cryptoStream As CryptoStream = New CryptoStream(memoryStream, Me.encryptor, CryptoStreamMode.Write)
            cryptoStream.Write(Me.enc.GetBytes(sPlainText), 0, sPlainText.Length)
            cryptoStream.FlushFinalBlock()
            Me.txtPasswordLogin.Text = Convert.ToBase64String(memoryStream.ToArray())
            If Me.TblAccountTableAdapter.FillByLogin(Me.DbAccountDataSet.tblAccount, Me.txtPasswordLogin.Text, txtUsername.Text) Then
                txtPasswordLogin.Clear()
                MessageBox.Show("Matched")
            Else
                txtPasswordLogin.Clear()
                MessageBox.Show("Not match")
            End If
            memoryStream.Close()
            cryptoStream.Close()
        Else
            MessageBox.Show("Please fill the textbox")
        End If


Only password was encrypted into database, in this login form I enter the exact name and encrypt it to match the character that was already saved on my database.

Encryption in VB.NET

The exact value of that password was joannou, and once the encryption was made only decryption can retrieve to display what the hash key word means.

Decryption will cover for my next tutorial.

The Purisimian Apps

Welcome to Purisimian Apps

Sample Screenshots: Watch sample video
Splash Screen

Home


Everyone that has an Android Phone can use these apps. It works offline, once you already install on your android phone, wherever you are you can use this apps as your guide and references about Colegio de la Purisima Concepcion.

In online services, you can access through Google map to view the geographical location of CPC both main and annex campus, send direct email, and student’s inquiry.

Purisimian Apps can only install in various android devices. Compatibility not yet tested in all android versions but it was tested on Ginger Bread, Ice Cream Sandwich, and Jelly Bean.

This serves as a guide for all students wants to enroll at Colegio de la Purisima Concepcion.

Here are the download links:

Saved data into a text file in java


FileWriter is meant for writing streams of characters. A FileWriter(File file,boolean append) constructors.
file - a File object to write to
append - if true, then bytes will be written to the end of the file rather than the beginning.

Without specifying boolean value to true, it will overwrite every time you add new items. Here are the codes:

import java.io.*;
import java.util.*;
public class Fileinputtext
{
    static Scanner input = new Scanner(System.in);
    public static void main(String[]args)throws IOException
    {
        String name,fname,lname;
        double hoursworked;
        double payrate;
        char ch;
        File f = new File("test.txt");
        try
        {
            //true so that not to overwrite while saving data to a textfile
            FileWriter fw = new FileWriter(f,true);
            System.out.println("Enter your firstname: ");
            fname = input.nextLine();
            System.out.println("Enter you lastname: ");
            lname = input.nextLine();
            System.out.println("Enter your hoursworked:");
            hoursworked = input.nextDouble();
            System.out.println("Enter your payrate:");
            payrate = input.nextDouble();
           
            name = fname + " " + lname;
           
            fw.write("Name: " +name + " Hoors worked: " + hoursworked + " Payrate: " + payrate + ":");
         
            //compute();
            System.out.println("Success");
            fw.close();
            System.out.println("Do you want to see the computed output? y/n: ");
            ch = input.next().charAt(0);
            switch (ch)
            {
                case 'y':
                case 'Y':
                compute();
                break;
                case 'n':
                case 'N':
                System.out.println("System will automatically closed");
                default:
                System.out.println("Error");
                break;
            }
        }catch (Exception ex){
            System.out.println("Error");
        }
       
    }
    public static void compute()throws IOException
    {
       Scanner infile = new Scanner(new FileReader("test.txt"));
      
       String fname,lname,name;
       double hoursworked,payrate,wages;
      
       fname = infile.next();
       lname = infile.next();
      
       hoursworked = infile.nextDouble();
       payrate = infile.nextDouble();
      
       wages = hoursworked * payrate;
       name = fname + " " + lname;
       System.out.println(name + " "+ wages);
    }
}

3 attempt login in vb.net using console


Login using console in vb.net with 3 times attempt. The user prompt to login the system, once it reach a maximum attempts the program will automatically closed.

Private Sub login()
        Dim user As String
        Dim pass As String
        Dim x As Integer

        Dim log As Boolean = True

        While log

                Do While x < 3
                    Console.WriteLine("Enter username")
                    user = Console.ReadLine()
                    Console.WriteLine("Enter password")
                    pass = Console.ReadLine()

                    If user = "admin" And pass = "123" Then
                        Console.WriteLine("Welcome! You're logged in.")
                        Console.ReadLine()
                        log = False
                        Exit While
                    Else
                        x += 1
                        Console.WriteLine("===========Error============")
                        log = True
                    End If
                Loop
                Console.WriteLine("3 times attempt, the program will automatically closed!")
                Console.ReadLine()
                Exit While

        End While

    End Sub

This program is quite simple. Hope this is very helpful.