Simple Example of Connecting Database Using Data Environment

Submitted by: 
Language: 
Visitors have accessed this post 51917 times.

In this program you will learn how to connect to the database using Data Environment. This is one of the features of Visual Basic to easily connect to the database without hard coding.

If you are familiar with MS Access you will most likely find it easy to deal with Data Environment. By using Data Environment you can easily drag fields from command object to your form. You can also create command based on stored procedures, tables, views, synonyms, and SQL statements.

Another feature is how you relate child form from the parent form. This can be done by relating one or more Command objects together.


Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.

Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.

FOR YOUR OWN SAFETY, PLEASE:

1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.

Comments

Hi i recently sent out a msg but i wasn't sure whether you got it. My request was that kindly assist me with the online hotel reservation and booking system using php,Mysql,html etc . i shall be grateful. ciao let me know ASAP

Sorry but I'm too kinda busy right now.

Hey jay i know ur kinda busy. during your free time pliz spare some time and bail me out. i shall be gratefull. by the way i find the hotel reservation system using vb 6.0 an excellent work you did. all the areas are covered. ciao

HELP ME PLEASE.. I WANT TO KNOW IF THERE IS A REGULAR EXPRESSION IN VB.NET. IF THERE IS, I WANT TO KNOW HOW TO USE IT.. THANK YOU VERY MUCH..
-bernadeth

Sir meron ka po bang combo box kapag pumili ako sa combo box yung mga details niya lalabas sa datagrid? help nman po salamat

Send me the database and I will create this for you.

Sir Jay,

Na send ko na po yung database nasa book ko na send eh hindi ko lam kung pano mag send sau eh.

thanks for the time

I actually uploaded the project. Please take a look at this link: http://www.sourcecodester.com/tutorials/visual-basic-net/display-record-datagridview-based-combobox-selected-value.html.

And please next time obey the rules. Write in English only. Thank you

Thanks you Sir Jay,

one more question can i convert this to vb6?

Yes only if you know how to convert it.

i will search for the convert vb.net to vb6 thanks sir

sir Jay i dnt know how to convert vb.net to vb6

Thanks Sir Jay, i will search for the convertion ofthat

I want to develop " School management system in visual basic" so i need some help from your side.
Thank you

sir do you have a codes of custom system!!! we need it tomorrow.

thankz in advance............!

help me please i have program in vb6 for raw material i need code for date
when i write this day's date the report show me stock out from the begening until today and also stock in and stock now, because my program does not show me the total it's show the stock out , stock in and balance for the date that i write it only please help me for that and thank you very mutch

amer
[email protected]
yemen

Without seeing your code I think it's hard for me to help you.

hi there... i am a visual foxpro programmer, i wanna learn some techniques in programming visual basic 6.0. can you send me a simple program regarding payroll system written in vb6.0? thanks and more power to your blogs.

[email protected]

Dim obj, rs As ADODB.Recordset, sql As String
Set rs = New ADODB.Recordset

If Ddate.Value <> "" Then
sql = "SELECT * FROM store ORDER BY [ProductID]" _

End If
rs.Open sql, cn, adOpenStatic
If Not rs.EOF Then
'Set DataReport1.DataSource = rs.DataSource

Set DataReport2.DataSource = rs.DataSource
For Each obj In DataReport2.Sections("Detail").Controls
If TypeOf obj Is RptTextBox Then
obj.DataMember = rs.DataMember
End If
Next
DataReport2.Sections("Detail").Controls("Text1").DataField = "DateAlias"
DataReport2.Sections("Detail").Controls("Text2").DataField = "ProductID"
DataReport2.Sections("Detail").Controls("Text3").DataField = "ProductName"
DataReport2.Sections("Detail").Controls("Text4").DataField = "TotalQty"
DataReport2.Sections("Detail").Controls("Text5").DataField = "TotalQty_SO"
'DataReport1.Sections("Detail").Controls("Text6").DataField = "tot1"
'DataReport1.Sections("Detail").Controls("Text7").DataField = "TotalQty_SR"
DataReport2.Sections("Detail").Controls("Text8").DataField = "Balance"
'DataReport1.Refresh
'DataReport1.Show
'Set rs = Nothing
DataReport2.Show vbModal

End If

End Sub

sorry for dely reply up is the but i need when i select date in Ddate ineed in report to colcolate the stock out field from begening 2010 to that date i select it and other field also like stock in and balance can you please help me and send me as soon as possible

thanks alooooooooooooooooooooooot
amer
yemen

dear admin

can you please help me about this subject i sent the code and this problem can select fanction solve it can you make it please and send it to me i am very hurry about this

p.s.

i need colcolate stock out and stock in from date to date which i select it in pick1 and pick2 for example .

thanks alot

ameer

i send the code to and i have not recieved your reply can please send the code to my private e-mail

[email protected]
amerr

i need the code which make to me the stock out and in from date to date otherwise that colcolat the stock from the date and to date i write it in pick

thanks
ameer

Any source code for an Electricity Billing System using Visual Basic with a Ms Access Database?

please help me in my software project,,i cant do this program,.. the amplitude exam..vb6 with 2003 access.please sir help me..sir email me [email protected] you

sir can you please give me a sample Payroll system in VB6.0

here is my e-mail: [email protected] thanks a lot..

Hi sir jay can you please help me with a call login system i've been trying the whole month and i still can't the windows application to communicate with the database on visual studio. my email is [email protected] thanx in advance

hi i have made this program and im facing a problem in the search button im using VB6 and data environment with access 2003

i need to search by first name only or sirname from the whole name plz plz help here the code :

Private Sub Command2_Click()
y = InputBox(" enter the name plz ")
If y = vbCancel Then
Exit Sub
ElseIf DataEnvironment1.rsCommand1.RecordCount = 0 Then
MsgBox ("no data")
ElseIf y <> "" Then
DataEnvironment1.rsCommand1.MoveFirst
DataEnvironment1.rsCommand1.Find "Name = '" & y & " ' "
On Error GoTo picer
x = "c:\pix\" + Text1.Text + ".jpg"
Image3.Picture = LoadPicture(x)
picer:
Exit Sub
If DataEnvironment1.rsCommand1.EOF Then
MsgBox ("not registed")
DataEnvironment1.rsCommand1.MoveFirst
End If
End If
End Sub

how to put edit?

i need the simple data base connection coding for VB with oracle data base and i need the explanations also can u send me that in my id

[email protected]

thanks jay

HI SIR I JUST WANNA ASK HOW TO CONNECT COMBO BOX IN DATA REPORT.. I HAVE A PROBLEM HERE THAT MY COMBO BOX WHICH IS IN OTHER FORM CANNOT CHANGE THE SQL STATEMENT THAT IS ON MY DATA ENVIRONMENT.. THE SITUATION IS THAT I HAVE A FORM WHICH HAS RECORDS OF COMPUTER COMPONENTS REGARDING WHAT LOCATION WERE ARE THEY ... EXAMPLE THE LOCATION IS IN ROOM 401, IT SHOULD CHANGE THE SQL STATEMENT INTO "SELECT * FROM INVENTORY WHERE LOCATION = "ROOM 401" SO THAT WHEN I PRINT RECORDS THEY ARE IN BY ROOM ORDER... THNX

REPLY ME AT MY EMAIL...

[email protected]
thnnnxx a lot sir...

KEITH

Hi, I'm am currently doing my internship in a company. My topic is Museum Management System which has to deal with some RFID technology. However, I'm very new in IT field, it's kind of difficult for me to do it. I'm wondering if you can guide me? I hope to keep in touch with you. Thank you

i have created a data report in vb6 with data environment. it is running ok. but the problem is when i want to change the connection of the data report to the database.
i have many database and i want a single report to display their contents by choosing from a list what database to use.
can you send me a sample of how to do this.

thanks,
Dadang

sir in my enrollment system program,the record didn't display at form edit.here is the code:
Private Sub cmdsave_Click()
adoedit.Recordset.Fields("studentnumber").Value = txtnumer.Text
adoedit.Recordset.Fields("lastname").Value = txtlast.Text
adoedit.Recordset.Fields("firstname").Value = txtfirst.Text
adoedit.Recordset.Fields("middlename").Value = txtmiddle.Text
adoedit.Recordset.Fields("address").Value = txtaddress.Text
adoedit.Recordset.Fields("nationality").Value = txtnationality.Text
adoedit.Recordset.Fields("religion").Value = txtreligion.Text
adoedit.Recordset.Fields("gender").Value = txtgender.Text
adoedit.Recordset.Fields("contactnumber").Value = txtcontactnumber.Text
adoedit.Recordset.Fields("cvilstatus").Value = txtcivilstatus.Text
adoedit.Recordset.Fields("course").Value = cmbcourse.Text
adoedit.Recordset.Fields("year").Value = cmbyear.Text
adoedit.Recordset.Fields("father").Value = txtfather.Text
adoedit.recordser.Fields("foccupation").Value = txtfoccupation.Text
adoedit.Recordset.Fields("mother").Value = txtmother.Text
adoedit.Recordset.Fields("moccupation").Value = txtmoccupation.Text
adoedit.Recordset.Fields("guardian").Value = txtguardian.Text
adoedit.Recordset.Update

MsgBox "information was successfully saved", vbOKOnly, "Record"

End Sub

sir can you help me with this?
thanks.laverne

Private Sub cmdsave_Click()
adoedit.Recordet.AddNew
adoedit.Recordset.Fields("studentnumber").Value = txtnumer.Text
adoedit.Recordset.Fields("lastname").Value = txtlast.Text
adoedit.Recordset.Fields("firstname").Value = txtfirst.Text
adoedit.Recordset.Fields("middlename").Value = txtmiddle.Text
adoedit.Recordset.Fields("address").Value = txtaddress.Text
adoedit.Recordset.Fields("nationality").Value = txtnationality.Text
adoedit.Recordset.Fields("religion").Value = txtreligion.Text
adoedit.Recordset.Fields("gender").Value = txtgender.Text
adoedit.Recordset.Fields("contactnumber").Value = txtcontactnumber.Text
adoedit.Recordset.Fields("cvilstatus").Value = txtcivilstatus.Text
adoedit.Recordset.Fields("course").Value = cmbcourse.Text
adoedit.Recordset.Fields("year").Value = cmbyear.Text
adoedit.Recordset.Fields("father").Value = txtfather.Text
adoedit.recordser.Fields("foccupation").Value = txtfoccupation.Text
adoedit.Recordset.Fields("mother").Value = txtmother.Text
adoedit.Recordset.Fields("moccupation").Value = txtmoccupation.Text
adoedit.Recordset.Fields("guardian").Value = txtguardian.Text
adoedit.Recordset.Update

MsgBox "information was successfully saved", vbOKOnly, "Record"

End Sub

hi

sir can you please give me a project of school management system in VB6.0 with back end as oracle.

here is my e-mail: [email protected] thanks a lot..

I want to get database design for school management system

sir how to create a dataflow diagram in reservation and ticketing system?
how to create a employee user name password,log in log out,at cia lng mkkbago ng password nia?
ganun din ang admin
super visor
cashier
customer

...how to display a out of stocks in a listview in visual basic 6.0...please replly..thank you

Sir, can you help me about Computer Laboratory Inventory (interface only) .I need it for my school project,hope you could help me about it.Thank you in advance.

sir can u teach me how to create a renting video codes using vb6and database and have a dataenvironment,sori 4 disturbing,i am freshmen student in computer programming..ned help

would u give me a sample codes of renting video using vb6 and mdbaccess and dataenvironment

Access data assign the vb form
the method of class project

access data one row value given one textbox
another textbox given access database column value
Now click on command button the MS-Access database particular row and column value display in Third Text box.

How to create, connection, coding with simple example

If you send the simple project my id?
my id is:- [email protected]

thank you.

dear sir please suggest me that how i show data in datagrid what i'll do for that please send me a project where use this e-mail ID [email protected] please sir..

sir can help me with my proposed thesis this sem, our proposal is student record management system for elementary school! can you suggest what is our design, IPO and HIPO because I don't have any idea yet on what to do! my email is: [email protected], kindly send me! thank you very much.

Dear Sir following is my code to view equipment history report as per year I typed in the text box code is successed but.I want to sort my equipment history report by month so please anybudy help me?

my mail ID=[email protected]

Private Sub PBY_Click()
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
If cn.State = adStateOpen Then cn.Close
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\CSP.mdb" & ";Persist Security Info=False;Jet OLEDB:Database Password=csp"

rs.CursorLocation = adUseClient
rs.Open "SELECT Date,Month,Year,Name_of_Parts_Replaced, Reason_of_Replacement, Maintenance_job_description, Notification_No,Serviced_by,remarks From DC1AHISTORY WHERE year ='" & search.Text & "'", cn, adOpenKeyset, adLockOptimistic

Set DC1AHistoryPRN.DataSource = rs

DC1AHistoryPRN.Show

End Sub

how to print bill on ms word sir plz help me

sir help please....i have a command1_grouping my problem is when i filter rscommand1 from dataenvironment the vb dont recognize the rscommand1
thanks in advance

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • You may insert videos with [video:URL]
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th> <img> <h1> <h2> <h3> <iframe> [video]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.