Posts

Showing posts from 2018

VB.net connecting to SQL Server

Connecting to SQL server 2014 from VB.Net 2017, read values from the database and display the data in windows form. Before begin to write this program, first we need to import SqlClient class. Imports System.Data.SqlClient Step 1 Create a sql connection object. This is to make connection to object. Dim conn As New SqlConnection() Step 2 Set the connection string to the sqlconnection object: conn.ConnectionString = connStr Road block The variable connStr is a connection string. Connection object need connection string to make connection to database. It has information like who providing the database, the name of the database and some security information. Dim connStr As String = "Data Source = ServerInstanceName;Initial Catalog=testDB;Integrated Security=True" Let's break down the connection string into the three main components. Dim provider As String = "ServerInstanceName;" Dim database As String = "Initial Catalog=testDB;" Dim

Setting up data set and display it

Before we display some data in DataGridView control in Visual Basic window we must create a data set. Data Set is an object that can hold data tables where all the data is stored in rows and columns. the first step is to create a table. Dim  dataTableObjectName as DataTable = New DataTable(tableName) this will create a table which is reference using the dataTableObjectName Example Dim userTable As DataTable = New DataTable("Users") Next step is adding columns to the table Dim column as DataColumn dataTableObjectName.Columns.Add (columnName, columnType) Example userTable.Columns.Add("userID", Type.GetType("System.Int.32")) ' adding second and third column userTable.Columns.Add("userName", Type.GetType("System.String")) userTable.Columns.Add("userContact", Type.GetType("System.String")) once we we columns in the table we can add row The rows contains records or the data for each user. dat

VB.net

a quick and convenient way to build a window based application. basically there is two main components in VB, the design view where we place the controls on a window form. then we have the code view where we write implementation for each controls on the form. Typically the control implementation or procedures are executed when certain events happens to the controls. Events like mouse click, or value change on text box, form load, form close and so on. After working with programming language like C, C++ and Java, getting use to VB is a bit challenging. its because first of all, VB don't use curly bracket to specify code blocks, and the statements don't end with semicolon. variable declaration for example is written as dim age As Integer in C, C++ and Java it written int age; in VB, variable declaration start with dim keyword, it means dimension and the functions are written as Function addNumber(ByVal num1 As Integer, ByVal num2 As Integer) As Integer addNumber

Controlling motor to affect rover movement direction

Image
This post is to capture finding on 2 wheeled rover movement   procedure. the rover is connected to Laptop via serial connection provided by Arduino micro controller which will be referred to as only Arduino. Command sent from laptop is interpreted by Arduino and sends appropriate signals to motor controller. The motor controller allows direction of the wheel rotation to be changed and supply power to the wheels both left and right. Arduino supplies 5 v to each wheels. And in the sense of direction of the wheels, its either in clockwise or anti clockwise. These can be achieved by changing the polarity of the terminals. When signal 1 is sent to these circuit, the wheel rotates clockwise and if signal 2 the wheel rotates anticlockwise. So, direction of a wheel rotation is controlled by a pair of signals. Since we have two wheels, left and right, each wheel rotation direction controlled by a pair of signal that comes from Arduino. This means we have 4 signals that comes into moto

Encryption concept

Encryption is a process of hide original information. Only an authorized person can read the hidden information. Used for protecting information sent from one point to another especially over network. Plain-text is not encrypted information or the original text. Encryption key is a secret value applied to plain-text to encrypt information. Cipher-text is the result of encryption process or encrypted information. Same encryption key needed to reverse this process to get original text. The reverse process is called decryption. Example Let say we want to encrypt following message "hello world" . Assuming that we have a table that assign a decimal value for each characters, such as a = 1 , b=2 etc. and continues to capital letters. The table also has special characters like space which equal 0. (Please refer to ASCII table for actual representation of characters). By comparing our message and character integer table, the message is represented by following sequen

Online gallery using div instead of table for page layout

Our online gallery up until previous post, used tables for setting layout for our gallery pages. Tables are primarily designed for tabulating data, not to layout page content. To define layout we should be using div tag. Our home page code shown below is modified to use div. To use div we should first get familiarized with CSS. <html>                <head>                               <title>Gallery| Home</title>                                                            <link rel="stylesheet" type = "text/css" href = "style/style.css">                                             </head>                <body>                                                                              <div style="width:20%; float:left;">                                              <!-- this is left space-->                               </div>                              

Online gallery database

Image
In previous post, message sent by visitor does not get stored in database. To use database we need PHP to get the data, connect to database and save the data there in database. Database that we are going to use is MySQL. Easiest and quickest way too use PHP and MySQL is to install XAMPP. After install your XAMPP copy the gallery folder, into server htdoc folder. Now type localhost/gallery/home.html  URL in your browser. The browser should be able to open the gallery home page. Make sure you have started Apache and MySQL from XAMPP control panel. Before saving the message from visitor into database, we have to create a database first. To do that, go to  phpMyAdmin page and create a database called  gallery. After the database is created, create a table called messageTable . Below is the entity diagram that represent the table. Next, create a PHP file  in the gallery folder. Open notepad  and type the following code. Save the file as saveMessaageToDatabase.php and select

Adding style to gallery

This post continues from previous blog where we  created online gallery website. In this post, we will add style to our pages. For this we will be using cascading styling sheet or CSS for short. The CSS codes are written inside notepad. Write the code written below in blank notepad (don't copy and paste) and save it as style.css in gallery folder.  a{                color: white;                background-color:gray;                padding: 15px;                text-decoration: none; } a:hover{                background-color:blue; } Don't forget to link this style sheet to your page. In home.html file, we need specify path to style sheet. Use <link> tag like shown below. <head> <title>Gallery| Home</title> <link rel="stylesheet" type = "text/css" href = "style.css"> </head> the hyperlinks now looks like button, when you move mouse on top of each bu

building online gallery

Image
Purpose of this website is to showcase picture collections.  This website only contain static pages without any functionality. To concentrate on website building environment with readily available applications like notepad and browser. Before dive into coding, always do some sketches to design your website. A simple boxes with page name would be enough to give your overall idea. adding your website content and edit them is always easy to do with paper and pencil. Design comes handy when your project become big and complex.websites which contains static pages like home, about us and contact us. We add another page which is specific for this web site gallery. Once your design is ready, we can dive into coding. Create a folder in desktop and name it gallery , all files belongs to web site will be saved here. First thing we will do is write a template. Your home page will be template for other pages. All web pages consist of code HTML code: <html>       <head>

Popular posts from this blog

Drawing Simple Pie Chart

VB.net connecting to SQL Server

VB.net