Database Guide

Level:
Level2

This Visual Basic 6 guide walks you step by step through VB6 tutorials and VB6 source code on this site that will help you learn how to develop applications that store and retrieve data from database back ends. As you read each of these database tutorials you will gain more and more knowledge in how to handle databases in your VB apps. The best way to navigate through the guide is by using the links on the left. Or you can use the links below and then hit your browser's back button. Each link will take you to a different vb6 database tutorial on this site that will teach you the next step you need in order to become a VB6 database guru.

  1. To do anything of value in Visual Basic related to databases you will first need to learn how to write SQL statements to extract what you want from your back end database. This applies to not only Microsoft SQL server but also to Access and Oracle databases. Learn how with this Introduction to SQL (Structured Query Language)
  2. The data control in VB6 allows you to interact with your backend database with out having to write all the code by hand. This is great when you are first learning how to do database development in Visual Basic or for quick and simple VB6 database applications. For more complicated applications you will probably use ADO. Still check out this Database Access with the VB6 Data Control tutorial to start getting your feet wet.
  3. This tutorial is optional as DAO is a somewhat older way of Visual Basic database development. However, if you ever have to interact with older code its good to at least understand the basics of this. Check out the Using DAO (Data Access Objects) Code Tutorial
  4. Again, RDO is still not the newest (and best) way to access back end data. However, there is a lot of VB database code out there that uses RDO so its probably good to at least glance through this tutorial in order to know what to do if you ever work on and VB RDO project. Database Access with RDO (Remote Data Objects) in VB6
  5. This is a must read! Visual Basic ADO development is the newest (and best) way to interact with any database. After walking through this tutorial you should be able to have every tool in your belt to grab data, modify it, and write back to any database you come in contact with. Any VB6 database developer must read this Database Access With ADO in VB6 tutorial
  6. Once you understand all the basics of how to use ADO to work with a database you will probably want to display that data to your end user in some way. One very effective way of doing this is with the list view that is built into the VB6 IDE. Using ADO and the ListView control in VB6
  7. It is bad programming practices to write all your SQL statments directly into your Visual Basic source code. This makes it hard to change things down the road and also has a performance disadvantage compared to using stored procedures. Learn how all this works in this tutorial: Using ADO and stored procedures in VB6
  8. If you ever need to print of reports for end users you might want to consider using Crystal Reports. Although many times you can get away with writing your own reports or exporting things to Excel or Word at times this isn't an option. Check out this Using Crystal Reports with VB6 tutorial to learn more about how to create these for your end users.
  9. Optional: This is optional because unless you are having to interact with an Oracle database you will never need to know this information. However if there is a time you need to use Visual Basic and Oracle together I recommend you check out this
  10. If you enjoyed this post, subscribe for updates (it's free)

I ALSO WANT THIS PLS SEND

I ALSO WANT THIS PLS SEND MAIL ON santoshsmishra1@gmail.com

Airline Reservation System

Airline Reservation System VB6

Use a one-dimensional array to represent the seating part of the plane. Initialize all the elements of the array to 0 to indicate that all seats are empty. As each seat is assigned, set the corresponding elements of the array to 1 to indicate that the seat is no longer available.
Your program should, of course, never assign a seat that has already been assigned, when the smoking section is full, your program should ask the person if it is acceptable to placed in the non-smoking section (and vice versa). If yes, then make the appropriate seat assignment. If no, then print the message “Next flight leaves in 3 hours.”

If the person types 1, then your program should assign a seat in the smoking section (seats 1-5). If the person types 2, then your program should assign a seat in the non-smoking section (seats 6 – 10). Your program should then show the person’s seat number and whether it is in the smoking or non-smoking section of the plane.

code for connecting Oracle with VB6

I want to connect Visual Basic with Oracle using ADO. pls send me the simplest code for that

VB6, DATAGRID, ADODC

do you have a code on how to search (name, establishment,contact,email,address,membership category) in datagrid using combo or any buttons ? help !!

pdf

hello . can anyone help me ... i need to store pdf in database and retrieve information from stored pdf .. how do i go about it ???? plz help

Store the path of the PDF in

Store the path of the PDF in the database.
Or store the path of the look up table in the database and let that reference the PDF.

Either way, its not a good idea to store such big objects in a PDF.
If you are intent on storing it there, I suggest you look up the OBJECT data type, that will fulfil your needs.

Need Help

Dear Sir,

I designed a form in VB. I placed 1textbox link with the database. now i can make the data entry. but in my database i have only one field called amount. in amount field there is more entries. my question is how can i calculate all the entries in amount field. Please help...

Looking forward your reply

Thanks

Seyed Ismail

Amount Sum

A very easy way to sum the amount field from your database is to use a SQL statement. A Data control will help you in this matter.

Here is a possible code:

Data1.DatabaseName = YourDataBase
Data1.RecordSource = "SELECT SUM(amount_field) as amountSUM FROM YourDataBase"
Data1.Refresh
Text1.Text = Data1.Recordset.Fields(0)

Calculate all the entries in amount field

Hi! Seyed,

First things first, I assume that your amount field data type is text/varchar, then you saved all the entries seperated by a comma as your delimeter.

Take a look at this example.

-----------------------------------------------------------------------------
Option Explicit

Private totalAmount As Double

Private Sub CalculateAmount(ByVal amount As String)

totalAmount = totalAmount + Val(amount)

End Sub

Private Sub cmdCalculate_Click()

Dim amounts() As String
Dim i As Integer

amounts = Split(Me.Text1.Text, ",")

For i = 0 To UBound(amounts)
CalculateAmount amounts(i)
Next

MsgBox totalAmount

End Sub

-----------------------------------------------------------------------------

You can change this code 'amounts = Split(Me.Text1.Text, ",")' to 'amounts = Split(rs.Fields("amount"), ",")' to split the rs.Fields("amount") value.

I hope this can help.

Best regards,
tobz

VB6.0-SQL Server 2000 database connectivity.

Sir, i am currently doing project on embedded systems and the control is given using VB6.0 (ADO-DB). But i need to connect the database file (MS SQL Server 2000) with that project file. May i get some help (Steps?) about 'how to connect that database file to VB Program'? I want to display all the data present in file into that program.

my project is computerized

my project is computerized menu card system front-end is vb and back-end is access...the main idea of my project is...in a restaurant every table has one computer system which has a menu form the details of menu is stored in one date base....user can check a desired food in check box and they enter their quantity at last total will be display to customer ant the menu data base is updated concurrently....and then control pass to server data base which make a bill to customer...My problem is ...i don't know how to connect menu database Particular details to to server database ? please send me a code...plz plz .i need a help

plss send me code

i want creat milk dairy project but my problem is that i don't how create datareport of one perticular member who give daily milk. i want create report for 15day all detail plss send code.

please help me how to connect my bar code scanner

please help me how to connect my bar code scanner using adodc
please give me a sample of codes and project this is my email!! vruin@yahoo.com thanks in advance

Help!!!!!

Please help!!!
I created a database to store a # so you never have to type it in again
but I don't know how to input that info into a textbox so I can Use it!!!!!!
Please I need Help ASAP!!!!!!!!!!!!!!

combobox

hi..i just need a help...how can i put all the names in my access in a combobox in vb6...thanks..

datagrid

ahh..how can i connect datagrid to access, to display the info in my datagrid..i am using DAO.Databse..thank you

connection using odbc to add info to database

'use this code to create and add info to a odbc connected database. first create a odbc connection by going to the controlpanel>administrative tools then name it as library. this is to make a media library.
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Sub add()
With rs
s = 1
.AddNew
!id = "11111"
!song = id3.Namea
!Artist = id3.Artist
!Album = id3.Album
!gener = id3.Genre_str
!Year = id3.Year
!Comment = id3.Comment
!FileName = id3.FileName
.Update
s = 0
End With
End Sub

Private Sub Command1_Click()
cmd.ShowSave
If Trim(cmd.FileName) <> "" Then
id3.FileName = cmd.FileName
Call add
End If
End Sub

Private Sub Command2_Click()
LIB.
End Sub

Private Sub Form_Load()
cn.Provider = "msdasql.1;persist security info=false;data source=library"
cn.Open
With rs
Set .ActiveConnection = cn
.CursorType = adOpenDynamic
.LockType = adLockOptimistic
.Source = "select * from songs"
End With
rs.Open
End Sub

use this to make a form with round edges

Option Explicit

Private Declare Function CreateRoundRectRgn _
Lib "gdi32" (ByVal X1 As Long, _
ByVal Y1 As Long, _
ByVal X2 As Long, _
ByVal Y2 As Long, _
ByVal X3 As Long, _
ByVal Y3 As Long) As Long

Private Declare Function SetWindowRgn _
Lib "user32" (ByVal hWnd As Long, _
ByVal hRgn As Long, _
ByVal bRedraw As Boolean) As Long

Public Sub CreateRoundRectFromWindow(ByRef oWindow As Object)

Dim lRight As Long
Dim lBottom As Long
Dim hRgn As Long

With oWindow
lRight = .Width / Screen.TwipsPerPixelX
lBottom = .Height / Screen.TwipsPerPixelY
hRgn = CreateRoundRectRgn(0, 0, lRight, lBottom, 40, 40)
SetWindowRgn .hWnd, hRgn, True
End With

End Sub

Private Sub Form_Load()
CreateRoundRectFromWindow Me

End Sub

how to create a licence for vb

Hi every one? is it possible to create a license file for use to activate a trial version of a project created in vb? Please help me? If this happens i want to create it and post it to this site to help others

Trial version of a project

Hi everyone. Please can anyone show me how to create a demo and a trial version for a project.

hi

im just asking if how to make a grading system and how to connect vb6 to ms access ?
And what the correct code of login admin and user ..
I hope you help me ..
Thank you ..

Data Show

Sir,
I'm connect the vb6 with sql server successfully but i don't under stand how to show the sql data in a vb from and print them.
Thank you,

sql server 2005

first you need to have a ms sql server 2005 (if you are using mssql) and the studio management. you can find that two on microsoft.com. the studio management is the one who will create for your database that can view to your vb project.

need help

hi sir,
i have a problem with searching data in db.
can i know what coding searching data in vb with no ID.
for example :when i click button search. all the data I need to go out.

Help please

con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\dbVMC.mdb;persist security info =false"

whats is the sql coounter part for vb6

re

"provider=microsoft sql server

hi sir/maam,

i am new in vb6 can u help me how to create a banking statement acc with micro access.. plsss.. plsss..

Data Tool Search , help me please

Hello
could you please help me
i have made a database
from the visual data manager in vb6 , its a Microsoft Access data
anyway
the table has 2 fields
1st called Name
2nd called ID

anyway
i have made 2 textboxes and added a DATA tool and everythings works but...
search , i want to search through the data base in the field ID to locate that worker or student or bla bla bla who has the same ID that i Enter In the Inputbox when i click search.

i need to search through the ID's to find the Same ID and show the whole file
Please E-Mail me the Answer
Anton.Thabaine@hotmail.com

trying to save txtURL bar

hi can some on help please trying to save what is in the txtURL bar an its history of web sites that i go to. need sum help with the coding if some one nows how to do it please help thanks

visual basic 6.0

sir,

i am doing a simple English Vocabulary project in VB6. i got a problem that do not know how to pass value from Text1.text in Form1 to Text3.text in Form2. pl help me

silvi

try

try dis one
form1.text1.text = form2.text3.text or vise versa

Passing value from one form to another form using Text Control

To pass a value a from one form to another, just use its name infront of text control.

See the example

1. Assume that the Form1's text control has some value like "Passing from one form to another" and its name is txt1.
2. In Form2, we have another text control named txt1 and in the Load event
txt2 = form1.txt1

There's no need to use "text" property of text control to access the value from it. Just specify the name of the text control

using listview

how to add data from listview into database ? thanks for your help

vb6 exe database on how to set file sharing connection

kindly help me to get this way out:

i have a vb6 database and created an exe file. Now i want to share this over network in different user with authorized user name accounts only. I just don't know how to established the file sharing and connection of the vb6.exe file because it has an error during they access it.

Thanks a lot

Sharing VB app over network

I'll get suspicious if you say it's worked successfully....
Just think, what you done?
Once you understand, everything will seems to be nothing...

Let me explain,
Assume that network has 3 systems namely system1, system2, system3.

In order to establish connection you specified the database path in source code. For example, D:\Projects\Somemgmt\mgmt.mdb in system1.

Whenever you run the application, it try to connect the database in the specified path in the local system. If you tried to make your application work over network, it'll show error message related to database because system2 or system3 doesn't have database in the specified. If you copy and paste the database in the exact locations in system 2 and 3, your application will fail.

To avoid these, instead of specifying path in source code, try to get the database from external sources. Use can use a notepad to store a database path and read the path from notepad in VB then connect database. For this purpose, you have to create two txt files to connect application with local as well as by other systems in network.

1. For local
dbpath_local.txt
D:\Projects\Somemgmt\mgmt.mdb

2. For network
dbpath_network.txt
system1\D\Projects\Somemgmt\mgmt.mdb

i need help.. urgent.. help pls...

Create a simple database in Ms Access. There should be at least 3 tables in the database. Create suitable forms in Visual Basic 6 and link all these forms to the database. Information in your database can be on an organization that you want to help or totally imaginary. You can discuss with your lecturer about your ideas and intentions.

This is the question.. i dont know how to do VB... can anyone help me????

i have done one program in

i have done one program in vb.
i have created one access file using visual data manager and i have inserted,deleted,updated the datas.
now i have to take printout.
please help me to take printout....

Please help me!!

Hi all,,firstly im so sorry if my english is bad,, im looking for the answer for my question :
"im using ms.access,,i want to bind records those have 'date' between certain dates, ex:
"SELECT * FROM TblA WHERE Date BETWEEN #02/02/2010# AND #01/03/2010#" , or
"SELECT * FROM TblA WHERE Date >= #02/02/2010# AND Date <= #01/03/2010#"
But the bound records are not like my expectation, because there are some dates those must be appeared but they didn't, also the opposite..
Please somebody help me....!

reply

change u r query to
select * from TblA where cvdate(date) between #mm/dd/yyyy# and #mm/dd/yyyy#

May be, your date parameters

May be, your date parameters are indian format (DD/MM/YYYY). Use the US format (MM/DD/YYYY)

help me write code for login form.

my form would be like this :

Username (textbox)
Password (textbox)

Ok(button) Cancel(button)

*can you please write the code for this form because i just don't get it how to do it :(

Password text control

Just make sure that the password char property of the password text is assigned with '*'. So, that the entered password will not be displayed as normal text input.

Go to the Properties.Then

Go to the Properties.Then find the PassworChar.then type *.. . . that alls!

u made a space in ur

u made a space in ur password textbox properties....crct it

LOGIN SYSTEM

LOGIN SYSTEM

Ok button will be (Command1)

if text1.text = "username" and text2.text = "password" then
'your codes you like confirming the right user and pass
else
msgbox"ERROR, please check if your username and password is corect"
end if

if u need question wix.com/zickgaming/zicktechnology
u can download some project in there

help me

can u help me how to edith database in adodb in visual basic can u gave me some example

Hi there

hi. . . i'm right now having my system., and my system is about computerized patient reservation and billing system for a clinic., and my problem now is., on how am i going to connect the calendar in the vb to the data base., what i want to happen is that in every day there will be a record for the patient reservation. i hope you guyz can help me., this website is really good

----------------

YOU NEED TO ADD SOME COMPONENTS/REFRENCES
TO GET THE DATE...............
TO KNOW MORE REPLY....

Using Pl/Sql code blocks.........

I was able to link vb and oracle using adodb.............
i used adodb.connection and record set..............
Now i want the data retrived from the database to be precise....
so i want to use Pl/sql codes
How do i do that
Plz help..............
Any starter clue will do................

vb6 datareport problem

hi, please help me. i've created database using access. i have a field of picture i use OLE Object. but in data report i cant bind that picture. pls help me. many many thanks!

vb 6.0

i am dng hostel info system project.....using vb6.0 and oracle...so pls help me 2 do that.....

help

i help u but u do more detail like what problem ..... u do some more details n i help u ......not only u any one can ... i help all

Re Assistance

Hi,
Send me an email with full details of your project and I will be helping you design that.

Kota

Hi

i would like you to help me design a data base for the university using vb
the database should be able to calculate students marks and grade them

Image Linking

How to use to the vb program in photo attached in vb code.
Please send me link this program in my email account. Thank you.

vb

i need your help please!!! "I want to relate different tables so that when a primary key of a record is entered on a different form it will be fetched from wherever it is stored.

I'll give an example on how

I'll give an example on how to joins because you didn't give enough information about you database structure

table 1
Name : student
Fields : name, studentid, age, dob
primary key: studentid

table2
Name : studentyear
Fields : studentyid, studentid, year
primary key: studentyid

The query string goes like this...
"SELECT NAME, AGE, DOB, YEAR FROM STUDENT INNER JOIN STUDENTYEAR ON
STUDENT.STUDENTID = STUDENTYEAR.STUDENTID WHERE STUDENT.STUDENTID = " & val(txtparam.txt)

codes

How to make a codes for Editing in database
management? tnx.. =)

How do I Change RecordSource Dynamically?

I have tried the following:

1. datTables.RecordSource = cbTables.Text

The Property value of the RecordSource is there and data does appear there but when I change it during run-time, the corresponding data does not appear.

What am I missing here?

Thanks for any assistance
Np3il

database data updating

i have created a table in access using visual data manager and adodc control in vb.now i want to edit and update data in that table what will be the vb commands for this purpose.i also want to know how we can compare two values in two different forms of same project in vb.plz help....

me i know the code for save

me i know the code for save in vb 6.0

can you pls. give the code

can you pls. give the code sir., for add edit delete and save.

HIGH SCHOOL GRADING SYSTEM

sir, can you please give me any example or link where i can find an example of a high school grading system using vb 6.0..
i tried to search on the internet but unfortunately i got nothing so please sir help me ... thanks in advance.

reply

set a select case by checking the total

ex if total>60
then grade="a"

end if
loop through the recordset

vb

how to display the records from database and how 2 update it..
plz give out the codings for this..based on login form for payroll systems...

Codes

I just want to know the exact code of connecting mysql to vb6 using the project in recording/saving data and print it.
plssss.

command search button

hey i really need help my search button is not working this is my code. the table in microsoft acces is named products.
Private Sub CmdSearch_Click()
sql = "Select * from products where code=" & TxtCode.Text
'create a connection
Dim cn As New ADODB.Connection
cn.ConnectionString = "DSN=intense merchandising"
'create a recordset
Dim rs As New ADODB.Recordset
'open the connection
cn.Open
'execute the sql statement
Set rs = cn.Execute(sql)

If rs.EOF Then
MsgBox ("Record not Found")
Else
Txtprodname.Text = rs(1)
Txtquanincase.Text = rs(2)
Txtunitcost.Text = rs(3)
Txtquaninstock.Text = rs(4)
Txtcostperdoz.Text = rs(5)
Txtquansold.Text = rs(6)
Txtproddesc.Text = rs(7)
Txtquanbal.Text = rs(8)

End If
'Close Connection
cn.Close

End Sub

answer

sql = "Select * from products where code= '"& TxtCode.Text&"'",cn,1,2

i am making a dairy inventory project.

Sir ,i am making a dairy inventory project.please help me with the visual basic 6.0 code

good

good