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.