Wednesday, August 15, 2012

Visual Basic 6.0 part 2 - Inserting Data

This is a basic data inserting using Insert SQL statement for beginners.
1.) Make a table in your database name it tblData and has 3 fields name , age and gender . see the image below
2.) In your form  drag objects  2 textbox  ,1 combo box and 1 command button. Do not rename the objects and change the caption of the command button to SAVE.
3.) Go to combo box properties and go to list and then input Male and Female for your dropdown list.
4.)Lets start coding. Double-click the save button and then input the code. see the image below.


tips:BE CAREFUL number and string has different syntax if  your database value is string like ex. fullname use this  statement  ' " & text1 & " '  while the number value has no single quote " & text2 &". 

5.)After coding run the program.Input your name ,age and gender. Error will occurred if you leave it blank or input string to age.
 6.)after it successfully added!! check your database..

Enjoy :)

Part 3 will be displaying data from database using listview



No comments:

Post a Comment