How to use a database?

Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
11 posts Page 1 of 2
Contributors
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

How to use a database?
Dummy1912
Hello guys,

A few months ago a friend of my ask me to create a tutorial for working with a database
well i know it can be done with several ways

but i love this way because it easy to work with.
i use a .mdb file protexted with password
you can use one without password that up to you
i use ms offfice 2007

first of al you need a module file:
this code you need to add.
Code: Select all
Option Explicit On
Imports System.Data
Imports System.Data.OleDb
Imports Microsoft.Win32
Imports System
Imports System.IO

Module Module1

    Public EditFrm As New EditFrm

    Public strSql As String


    Public ConBill As New ADODB.Connection
    Public RsBill As New ADODB.Recordset

    Public RLArrayBill(0, 0) As String
    Public RLRnoBill(0) As Integer
    Public ReminderCountBill As Integer
    Public ContactListArrayBill(0, 0) As String
    Public ContactCountBill As Integer

    Public blnEditContactsBill As Boolean
    Public intRecordNoBill As Integer


    Public Sub OpenConBill()
        ConBill.CursorLocation = ADODB.CursorLocationEnum.adUseClient
        'Here we only gonna changed the name of the database and password
        ConBill.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
              Replace(Application.StartupPath, "bin", "") & "\DDB.mdb;Mode=ReadWrite|Share Deny None;Persist Security Info=False;User Id=admin;Jet OLEDB:Database Password=lopulopu"

'if your database has no password you should use this:  password;"

        ConBill.Open()

        RsBill.CursorType = ADODB.CursorTypeEnum.adOpenStatic
        RsBill.LockType = ADODB.LockTypeEnum.adLockBatchOptimistic
    End Sub

    Public Sub CheckConBill()
        If ConBill.State = 0 Then Call OpenConBill()
    End Sub

    Public Sub CloseConBill()
        If ConBill.State = 1 Then
            ConBill.Close()
        End If
    End Sub

    Public Function FixQuotesBill(ByVal thestring)
        FixQuotesBill = Replace(thestring, "'", "''")
    End Function
Code: Select all
#Region "Here i load everything needed in the ListView"
    Public Sub InitBill()
        Dim i As Integer
        'Here I load the database with the name of the table (mainpage)

        RsBill.Open("Select * from MainPage where id=" & intRecordNoBill, ConBill)
        ReminderCountBill = RsBill.RecordCount
        If ReminderCountBill > 0 Then
            ReDim RLArrayBill(ReminderCountBill, 9)
            ReDim RLRnoBill(ReminderCountBill)
            With RsBill
                'Hier zet ik alle waarden die in de mainpage zitten
                For i = 0 To ReminderCountBill - 1
                    RLArrayBill(i, 1) = .Fields!name.Value
                    RLArrayBill(i, 2) = .Fields!firstname.Value


                    RLArrayBill(i, 0) = .Fields!id.Value
                    RLRnoBill(i) = .Fields!id.Value

                    .MoveNext()
                Next
            End With
        End If
        RsBill.Close()

    End Sub

#End Region


End Module


i don't gonna add all the code here because its taking me a long time to add this and explain it
so here you can download the source.

good luck
Dummy1912
You do not have the required permissions to view the files attached to this post.
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
User avatar
Axel
Coding God
Coding God
Posts: 1928
Joined: Sun Jun 27, 2010 9:15 pm

Re: How to use a database?
Axel
Nice tutorial :)
But I don't work with databases often because thats boring programming :P
http://vagex.com/?ref=25000
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

Re: How to use a database?
Dummy1912
Axel wrote:
Nice tutorial :)
But I don't work with databases often because thats boring programming :P
hello buddy
i understand :D
and thanks
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
GoodGuy17
Coding God
Coding God
Posts: 1610
Joined: Mon Sep 07, 2009 12:25 am

Re: How to use a database?
GoodGuy17
The way you use databases looks far different than [urlhttp://homeandlearn.co.uk/NET/nets12p1.html]my way[/url].

Where did you learn your way? Like, from a website? YouTube video? Yourself?

It looks like good coding, and great code per se, so nice job. cooll;
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

Re: How to use a database?
Dummy1912
GoodGuy17 wrote:
The way you use databases looks far different than [urlhttp://homeandlearn.co.uk/NET/nets12p1.html]my way[/url].

Where did you learn your way? Like, from a website? YouTube video? Yourself?

It looks like good coding, and great code per se, so nice job. cooll;

i learn from some friends
so i personally think this way is easier then that way you showed me.
but it works thats the point :D
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
User avatar
Agust1337
Coding God
Coding God
Posts: 2456
Joined: Fri Feb 19, 2010 8:18 pm

Re: How to use a database?
Agust1337
Hey Tim,
Thanks I neither know much about database lol, but I will probable learn something now :D
Keep it up cooll;
Top-notch casual Dating
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

Re: How to use a database?
Dummy1912
thanks agust (buddy)

ill try :D
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
User avatar
MrAksel
C# Coder
C# Coder
Posts: 1758
Joined: Fri Mar 26, 2010 12:27 pm

Re: How to use a database?
MrAksel
Thanks for posting :)
I really was hoping you were gonna post this :D
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;


Over 30 projects with source code!
Please give reputation to helpful members!

Image
Image
User avatar
Codex
Coding God
Coding God
Posts: 2028
Joined: Wed Mar 31, 2010 5:50 pm

Re: How to use a database?
Codex
this is only for windows ms access, which i never tried, but is it secure to make the connection?
Connecting to mysql database isn't hard, i managed to make one, but closed it after realizing that its not safe.
Also, you need a remote database(not all hosts give that).
We shall let the revolution begin.. the revolution for freedom, freedom against censorship. We shall fight in the fields and in the streets, we shall fight in the hills; we shall never surrender
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: How to use a database?
mandai
Security depends on who is using the application.
11 posts Page 1 of 2
Return to “Tutorials”