Database Restore in vb.net

Database Restore in vb.net
firstly you need to add reference to COM component: Microsoft DAO Object Library to your project.
Project menu -> Add Reference -> COM tab -> Navigate to "Microsoft DAO 3.x Object Library
====================================================
Microsoft DAO Object Library to your project

Imports System.IO
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim sDBFile As String = Application.StartupPath + "/db_name.mdb"
Dim sBackUpFile As String = "E:\db_name.mdb"

'Restore the original file from the compacted file
If File.Exists(sBackUpFile) Then
File.Copy(sBackUpFile, sDBFile, True)
End If
End Sub
End Class
==============================================================

Easy method (simple method)
----------------------------------------------------------------------------------------------------
Imports System.IO
……………………………………………………………………………………………………………………………….
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim sDBFile As String = Application.StartupPath + "/db_name.mdb"
Dim sBackUpFile As String = "E:\db_name.mdb ‘any path
If File.Exists(sBackUpFile) Then
FileCopy(sBackUpFile, sDBFile)
End If
End Sub
End Class
===============================================================

Database Backup in vb.net

Database Backup in vb.net
firstly you need to add reference to COM component: Microsoft DAO Object Library to your project.
Project menu -> Add Reference -> COM tab -> Navigate to "Microsoft DAO 3.x Object Library
====================================================
Microsoft DAO Object Library to your project

Imports System.IO
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim sDBFile As String = Application.StartupPath + "/db_name.mdb"
Dim sBackUpFile As String = "E:\db_name.mdb"
' Backup *.mdb database
If File.Exists(sDBFile) Then
Dim db As New DAO.DBEngine
'CompactDatabase has two parameters, creates a copy of compact DB at the Destination path
db.CompactDatabase(sDBFile, sBackUpFile)
End If

End Sub
End Class
===============================================================

Easy method (simple method)
----------------------------------------------------------------------------------------------------
Imports System.IO
……………………………………………………………………………………………………………………………….
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim sDBFile As String = Application.StartupPath + "/db_name.mdb"
Dim sBackUpFile As String = "E:\db_name.mdb
If File.Exists(sDBFile) Then
FileCopy(sDBFile, sBackUpFile
End If
End Sub
End Class
===============================================================

How to select folder directory in vb.net

How to select folder directory
=====================================================================================
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
' First create a FolderBrowserDialog object
Dim FolderBrowserDialog1 As New FolderBrowserDialog
' Then use the following code to create the Dialog window
' Change the .SelectedPath property to the default location
With FolderBrowserDialog1
' Desktop is the root folder in the dialog.
.RootFolder = Environment.SpecialFolder.Desktop
' Select the C:\Windows directory on entry.
.SelectedPath = "c:\"
' Prompt the user with a custom message.
.Description = "Select the source directory"
If .ShowDialog = Windows.Forms.DialogResult.OK Then
' Display the selected folder if the user clicked on the OK button.
Lblpath.Text = .SelectedPath
Else
MessageBox.Show("Select directory")
End If
End With
End Sub
=====================================================================================

How To Eliminate Decimal Points In VB.net

How To Eliminate Decimal Points In VB.net

For example, i have number x= 12.13
i only want to show x= 12
and if i have another number x=12.89
i want to show x=13

========================================================================================
Dim y As Integer
Dim x As Double = CType(LABEL1.Text, Double)
y = Convert.ToInt32(x)
========================================================================================

How to take asc value in vb.net

Private Sub Txtbrandid_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Txtbrandid.KeyPress
Dim i As Integer = Asc(e.KeyChar)
MessageBox.Show(i)

End Sub

MS Access Different Select - Where Query


Operator



Description




Example



=




All data that Equals value



SELECT * from Member Payment WHERE Payment Amount=50



≪>



All data that does not equal value




SELECT * from Member Payment WHERE Payment Amount ≪> 50



>



All data that is Greater than the value



SELECT * from Gym Members WHERE Member Expire > 12/1/2006



≪



All data that is less than the value




SELECT * from Gym Members WHERE Member Expire ≪ 12/1/2006



>=



All Data that is greater than or Equal to the value



SELECT * from Gym Members WHERE Member Expire >= 12/1/2006



≪=



All data that is Less than or equal to the value




SELECT * from Gym Members WHERE Member Expire <= 12/1/2006



AND, OR



Used to Separate values being compared



SELECT * from GymService WHERE ServiceCost = 20 OR ServiceCost = 50



BETWEEN



Between two values including those two values



SELECT * FROM GymMembers WHERE MemberExpire Between 12/1/2006 And 2/1/2007




LIKE



Used to search for a string of alphabets, numbers, or other characters




SELECT * from GymMembers WHERE MemberName LIKE 'Jackie Smyth' OR MemberName LIKE 'Sid Harris'



IN




a


Used to search for a set of values



SELECT * from GymMembers WHERE MemberID IN (1,5,10,15,20)



How do I enable JavaScript in my browser?

How do I enable JavaScript in my browser?

In order to view Google ads on a website, you will need to have JavaScript enabled in your browser. To do so, please follow the instructions below:

Internet Explorer (6.0)

  1. Select 'Tools' from the top menu

  2. Choose 'Internet Options'

  3. Click on the 'Security' tab

  4. Click on 'Custom Level'

  5. Scroll down until you see section labled 'Scripting'

  6. Under 'Active Scripting', select 'Enable' and click OK

Netscape Navigator (4.8)

  1. Select 'Edit' from the top menu

  2. Choose 'Preferences'

  3. Choose 'Advanced'

  4. Choose 'Scripts & Plugins'

  5. Select the 'Enable JavaScript' checkbox and click OK

Mozilla Firefox (1.0)

  1. Select 'Tools' from the top menu

  2. Choose 'Options'

  3. Choose 'Web Features' from the left navigation

  4. Select the checkbox next to 'Enable JavaScript' and click OK

Mozilla Firefox (1.5)

  1. Select 'Tools' from the top menu

  2. Choose 'Options'

  3. Choose 'Content' from the top navigation

  4. Select the checkbox next to 'Enable JavaScript' and click OK

Apple Safari (1.0)

  1. Select 'Safari' from the top menu

  2. Choose 'Preferences'

  3. Choose 'Security'

  4. Select the checkbox next to 'Enable JavaScript'

Using cookies in JavaScript

Using cookies


This JavaScript example places one item from a set of items (tips, thoughts, quotes, banners)
on your Web page. It simply includes in your page one string from a big array.
Since the strings may be long and may contain any HTML tags, you can easily create,
for example, banner rotation.


Each time the page loads, a new item will be displayed.
Every visitor has his own counter stored in a browser cookie.



<html>

<body>



<script type="text/javascript">


<!--

var count=document.cookie.indexOf("cnt=");

if(count>=0) count=document.cookie.substring(count+4);

else count=0;

document.cookie = "cnt=" + (count+1) + ";expires=Fri,1 Jan 2010 00:00:00";

var aStrings = new Array(

"<a href='index.html'>Home Page</a>",


"<a href='examples.html'>JavaScript Examples</a>",

"<a href='tutorials.html'>JavaScript Tutorials</a>"

);

document.write(aStrings[count%aStrings.length]);

//-->


</script>



</body>

</html>

This script uses a cookie (a small file that gets written onto your hard disk by JavaScript
from the Web site you're visiting) to store the variable count.
This variable is incremented every time the page is loaded, and is used as an index of the
array aStrings, which contains HTML strings.

Image swapping using JavaScript

Image swapping


Here's the classic mouseover button effect that shows one image when it's left alone,
and another when the mouse passes over it...



<html>

<head>

</head>

<script type="text/javascript">


<!--

function PreloadImages() {

var aImages = new Array('img12.jpg','img22.jpg');

for(var i=0; i < aImages.length; i++) {

var img = new Image();

img.src = aImages[i];

}

}


//-->

</script>

<body onLoad="PreloadImages()">



<a href="index.html"

onMouseOver="document.img1.src='img12.jpg';"

onMouseOut="document.img1.src='img11.jpg';">

<img src="img11.jpg" name="img1">




<a href="javascript-examples.html"

onMouseOver="document.img2.src='img22.jpg';"

onMouseOut="document.img2.src='img21.jpg';">

<img src="img21.jpg" name="img2">



</body>

</html>

In the above JavaScript example there are two graphic buttons, one called "img11.jpg" and the other called "img21.jpg." The buttons contain onMouseOver and onMouseOut instructions that change the image objects from "img11.jpg" to "img12.jpg" and from "img21.jpg" to "img22.jpg" respectively, and back again.

The body tag has an event handler called onLoad, which calls the function PreloadImages once a page finishes loading. This function creates an array of the names of images to preload, and then creates a new Image object for each name.

This makes the browser to preload all images and store them in the cache when the page first loads, before any rollover action. It's necessary for instant image swapping

Drawbacks of JavaScript

The drawbacks of JavaScript

Right now the biggest problem is the imperfect JavaScript implementations that today's browsers offer. Although all major browsers that are version 3.0 or higher include JavaScript support, they deal with JavaScript differently.

In fact, different versions of the same browser handle JavaScript differently. This makes it difficult to create a complicated JavaScript code that work across all browsers. So always check your pages on as many different browsers (and even platforms) as possible.

JavaScript code that prints current date in the top right corner of your Web page

JavaScript code that prints current date in the top right corner
of your Web page...



<html>

<head>

<script type="text/javascript">

<!--

function PrintDate() {


today = new Date();

document.write('Date: ', today.getMonth()+1, '/', today.getDate(), '/', today.getYear());

}

//-->

</script>

</head>



<body>

<p align="right">


<script type="text/javascript">

<!--

PrintDate();

//-->

</script>

</p>

THE REST OF YOUR PAGE.

</body>

</html>

Simple JavaScript code

What do JavaScript code look like?


Like HTML, JavaScript is just text that can be typed into a text editor. Its code is embedded
in HTML within a <SCRIPT> tag. Some old browsers don't understand this tag.
To prevent them from treating your JavaScript as HTML, always use this trick involving HTML comments...



<script type="text/javascript">

<!-- hide JavaScript code from old browsers

YOUR SCRIPT HERE


// end the hiding comment -->

</script>

List of the common event handlers in java script



























EventWhen it's triggered
onAbortAn image is stopped from loading because the user either hits Stop or leaves the page.
onBlurAn element, such as a window, frame, or form field, loses focus; that is, when the user clicks on something else.
onClickThe user clicks on the particular element.
onChangeThe value of a form field changes, for example, when the user types in some data.
onDblClickThe user double-clicks on the particular element.
onErrorA loading error happens, like a missing image.
onFocusThe user puts the focus on the target element, by clicking on it or tabbing to it.
onKeyDownA key on the keyboard is pushed down, regardless of whether it's then held down or released.
onKeyPressThis event is repeatedly triggered as long as a key is held down.
onKeyUpA key on the keyboard is released.
onLoadThe browser completely loads the page.
onMouseDownA key on the mouse is pushed down, regardless of whether it's then held down or released.
onMouseMoveThe mouse moves.
onMouseOutThe pointer moves out of the target area.
onMouseOverThe pointer moves over the target element.
onMouseUpA key on the mouse is released.
onResetThe Reset button of a form is clicked.
onResizeA window or frame is resized by the user.
onSelectThe user highlights text in a form field.
onSubmitA form is submitted.
onUnloadThe user leaves the page.

What is JavaScript?

What is JavaScript?

JavaScript is a compact, object-based scripting language for Web pages. JavaScript code embedded into your HTML pages can enhance them with many interesting elements, from swapping images when you move a cursor over them, to multi-level drop-down menus.

You can create really sophisticated and almost application-like pages with the help of JavaScript. You don't need any special software other than a text editor and a Web browser, and you don't need access to a Web server. You can create and test all your JavaScript code right on your own computer.

PHP mail script

Simple PHP mail script


This script is not only educational, but also applicable for practical Web development.
It allows you to place a simple form for sending emails on any HTML page. The script shows
you how to gather user input, perform form validation with PHP, and send an email.First, make the form page mail.html (you may call it whatever you like)...

<html>

<head><title>Mail sender</title></head>

<body>

<form action="mail.php" method="POST">

<b>Email</b><br>


<input type="text" name="email" size=40>

<p><b>Subject</b><br>

<input type="text" name="subject" size=40>

<p><b>Message</b><br>

<textarea cols=40 rows=10 name="message"></textarea>


<p><input type="submit" value=" Send ">

</form>

</body>

</html>

The form contains the necessary text fields Email, Subject, Message, and the Send button. The line

<form action="mail.php" method="POST">

tells the browser which PHP file will process the form and what method to use for sending data.


When the user fills in the form and hits the Send button, the mail.php file is called...



<html>

<head><title>PHP Mail Sender</title></head>

<body>

<?php



/* All form fields are automatically passed to the PHP script through the array $HTTP_POST_VARS. */


$email = $HTTP_POST_VARS['email'];

$subject = $HTTP_POST_VARS['subject'];

$message = $HTTP_POST_VARS['message'];



/* PHP form validation: the script checks that the Email field contains a valid email address and
the Subject field isn't empty. preg_match performs a regular expression match. It's a very
powerful PHP function to validate form fields and other strings - see PHP manual for details.
*/

if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $email)) {

echo "<h4>Invalid email address</h4>";


echo "<a href='javascript:history.back(1);'>Back</a>";

} elseif ($subject == "") {

echo "<h4>No subject</h4>";

echo "<a href='javascript:history.back(1);'>Back</a>";


}



/* Sends the mail and outputs the "Thank you" string if the mail is successfully sent,
or the error string otherwise.
*/

elseif (mail($email,$subject,$message)) {

echo "<h4>Thank you for sending email</h4>";


} else {

echo "<h4>Can't send email to $email</h4>";

}

?>

</body>

</html>


As you see, the script is simply one if ... elseif ... else statement.
At first, it validates the required form fields. Note that PHP form validation is performed
on the server, after sending all the data. Therefore, it would be a good idea to combine
server-side form validation with PHP and client-side form validation with JavaScript in order to
avoid unnecessary data sending.

If the email address is valid and subject isn't empty, the script sends the mail and displays
the corresponding message. Note how the variable $email is included into the output string.

You can also use this script to implement the safe "Contact Us" function on your website.
Your visitors will be able to send you a message, but your email address won't be displayed
on the page and spam bots, that parse pages looking for potential email addresses, won't get it.

Just remove the Email text field from the form and replace the first line of the script with
something like...

$email = 'YourAddr@YourMail.com';

And, of course, you don't need to validate the email address in this case.

What is PHP? ?

What is PHP?


PHP, which stands for "Hypertext Preprocessor", is a server-side,
HTML embedded scripting language used to create dynamic Web pages. Much of its syntax is borrowed
from C, Java and Perl with some unique features thrown in. The goal of the language is to allow Web
developers to write dynamically generated pages quickly.


In an HTML page, PHP code is enclosed within special PHP tags. When a visitor opens the page,
the server processes the PHP code and then sends the output (not the PHP code itself) to the
visitor's browser. It means that, unlike JavaScript,
you don't have to worry that someone can steal your PHP script.


PHP offers excellent connectivity to many databases including MySQL, Informix, Oracle, Sybase,
Solid, PostgreSQL, and Generic ODBC. The popular PHP-MySQL combination (both are open-source products)
is available on almost every UNIX host. Being web-oriented, PHP also contains all the functions
to do things on the Internet - connecting to remote servers, checking email via POP3 or IMAP,
url encoding, setting cookies, redirecting, etc.


What do PHP code look like?


PHP is a rather simple language. Much of its syntax is borrowed from C except for dealing with
the types of variables. You don't need to think of the types of variables at all - you just
work with their values, not their types. And you don't have to declare variables before you use them.


Basic Syntax


  • File name:

    You should save your file with the extension .php (earlier versions used the extensions .php3 and .phtml).


  • Comments:

    // This comment extends to the end of the line.

    /* This is

    a multi-line

    comment
    */

  • Escaping from HTML:

    A PHP code block starts with "<?php" and ends with "?>". A PHP code block can be
    placed anywhere in the HTML document.


  • Instruction separation:

    Each separate instruction must end with a semicolon. The PHP closing tag (?>) also implies
    the end of the instruction.


Here's a small PHP example...



<html>

<head><title>Example</title></head>


<body>

<h1><?php echo "Hello World"; ?></h1>

<?php

$txt = "This is my first PHP script";

/* This line creates the variable $txt and gives it the initial value. Variables in PHP are represented by
a dollar sign followed by the name of the variable. The variable name is case-sensitive.
*/



echo $txt;


?>

</body>

</html>

How to connect MYSQL 5.0 database to vb.net

To be able to create this program you must have basic knowledge concerning mySQL 5.0 as well as vb.net.

Prerequisite:
1. mySQL Server 5.0
2. mySQL Dot Net Connector 5.1
3. VB.net Express edition/ VB.net Family

Steps:

1. Install first mySQL Server 5.0 and and mySQL Dot Net Connector.
2. Import the reference of mySQL DotNet Conenctor



How to add a reference to MySql.Data.dll" means you need to add a library
• Create a new project in Visual Studio
• In the Solution Explorer, under the project name, locate References and right-click on it. Select "Add Reference".
• In the "Add Reference" dialog, switch to the "Browse" tab and browse to the folder containing the downloaded connector. Navigate to the "bin" folder, and select the "MySql.Data.dll" file. Click OK

Code for reading data from mysql data base
=====================================================================================
Imports MySql.Data.MySqlClient
Imports MySql.Data.MySqlClient.MySqlException
Imports MySql.Data.MySqlClient.MySqlCommand
Public Class Form1
Public con As New MySqlConnection
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim con As MySqlConnection = New MySqlConnection("Data Source=localhost;Database=test1;User ID=root;Password='';")
Dim sql As MySqlCommand = New MySqlCommand("SELECT * FROM tablename", con)
Dim ds As DataSet = New DataSet()
Dim DataAdapter1 As MySqlDataAdapter = New MySqlDataAdapter()
con.Open()
DataAdapter1.SelectCommand = sql
DataAdapter1.Fill(ds)
End Sub
=====================================================================================

Electrical Projects

Electrical Projects


1. Intelligent AMR(Automatic Meter Reading) with GSM

2. SCADA for Substation & Distribution

3. GSM based Power station Switching

4. Electrical Home Automation

5. Industrial Automation using GSM

6. SCADA for large industrial automation

7. MOSFET based PWM inverter using Microcontroller

8. Telemetry module for a Real Robot

9. Handheld Data Logger

10. Digital Panel Meter with Voltage, Current & Frequency using Microcontroller

if u have any suggestions contact me