Symbianize





Programming Discussions related to C++, HTML, PHP, ASP, ColdFusion, JavaScript, Perl, Phyton, Ruby, WML, SQL, XML, and other programming languages.

Reply
  #11  
Old 20th Jun 2010 Sun, 14:23
ako2's Avatar
ako2 Male ako2 is offline
Forum Advisor
 
Join Date: Mar 2009
Location: Shadow Island
Posts: 535
Reputation: ako2 is an unknown quantity at this point
Default Re: VB.NET Programming Corner!

Quote:
Originally Posted by ericgmejia View Post
First Post:

Populating DataGridView using MSAccess Database



Shown in 3ways
-using Dataset
-using DataReader
-binding the DataGridView to a dataset



Important points to learn:
OleDBConnection
OleDBCommand
OleDBAdapter
Dataset
DataReader
DataTable
Using My.Settings to save the database path

Program will search for the database if not found;
Sample code has comments as to how it is done
Post further questions if necessary:

Basic Steps:

Create a project:
Add a form:
Add this to the forms top most code
"Imports System.Data.OleDb"
Add the DataGridView
For non databound grid,
add the necessary columns using the datagridview designer (when selected; click the [>] button on the top rigth of the grid)
Follow the code provided


the file
ericVBNETAccess.rar
contains the design for the application series i wanted to construct for this thread
you will notice, walang pop windows, nasa tab page lang ang forms.
stay tuned to know how it is done.
medyo mahaba po yung code 'nyo, ewan ko kung best ba ito. Meron po akong ibang way.. Sunday kasi ngayon, nasa net cafe lang ako.. bukas, i.upload ko dito yung code ko in populating datagrid as ms access as backend! Wala kasi Visual Studio dito..



Reply With Quote
Other Resources
  #12  
Old 20th Jun 2010 Sun, 14:34
ericgmejia's Avatar
ericgmejia Male ericgmejia is online now
The Legend
 
Join Date: Dec 2007
Location: Makati City
Posts: 6,567
Reputation: ericgmejia will become famous soon enough
Default Re: VB.NET Programming Corner!

Quote:
Originally Posted by ako2 View Post
medyo mahaba po yung code 'nyo, ewan ko kung best ba ito. Meron po akong ibang way.. Sunday kasi ngayon, nasa net cafe lang ako.. bukas, i.upload ko dito yung code ko in populating datagrid as ms access as backend! Wala kasi Visual Studio dito..
as i said i presented 3 ways to do it, look at method3.

malamang naka bound ka sa isang design time datasource. i dont do that,
wala masyado control sa runtime pag ganun.
madami ka di pde gawin pag naka bound na yung grid.
which you will see as the samples progress.

what im showing here is also applicable to other controls not just datagridview.
and i want to show rin how it is done in code

the code is not only for datagridview, you can use the code in other operations as well.

if you have a better code to share then tignan natin, you can open your file naman sa notepad muna so we can see it.
baka di ko pa alam yang method mo.
share tayo ng mag codes and techniques. this is what this forum is for.



Give a man a computer program and you give him a headache,
but teach him to program computers and you give him the power to create headaches for others for the rest of his life..
VB.NET Programming Corner
VB6/MSAccess Using ADO with DataReport
Facebook, Other Threads
Join my shared folder in Dropbox get access to code samples, ebooks, tools and other usefull stuff

Last edited by ericgmejia; 20th Jun 2010 Sun at 15:10..
Reply With Quote
  #13  
Old 21st Jun 2010 Mon, 12:59
uchihame's Avatar
uchihame Male uchihame is offline
The Grand Master
 
Join Date: Jan 2010
Location: local disk (c:)
Posts: 4,035
Reputation: uchihame will become famous soon enoughuchihame will become famous soon enough
Default Re: VB.NET Programming Corner!

thanks po master..



UCHIHAME AKA MR.KEYBOARD
Reply With Quote
  #14  
Old 21st Jun 2010 Mon, 13:18
doorbreaker's Avatar
doorbreaker Male doorbreaker is offline
Forum Advisor
 
Join Date: Mar 2010
Location: earth
Posts: 909
Reputation: doorbreaker is an unknown quantity at this point
Default Re: VB.NET Programming Corner!

Question po, I made a class for reading and sending text messages and in that class I have a windows.forms.timer it is working perfectly fine so i tried to compile it as a class library and changed the windows.forms.timer to system.timers.timer when i tried to use it on the same program it has an error "Stack Overflow".

for people who don't know the difference between windows.forms.timer and system.timers.timer is windows.forms.timer can only be used on windows forms. surprised? hehehe

is there a difference on their behavior?



Reply With Quote
  #15  
Old 21st Jun 2010 Mon, 14:06
ericgmejia's Avatar
ericgmejia Male ericgmejia is online now
The Legend
 
Join Date: Dec 2007
Location: Makati City
Posts: 6,567
Reputation: ericgmejia will become famous soon enough
Default Re: VB.NET Programming Corner!

Quote:
Originally Posted by doorbreaker View Post
Question po, I made a class for reading and sending text messages and in that class I have a windows.forms.timer it is working perfectly fine so i tried to compile it as a class library and changed the windows.forms.timer to system.timers.timer when i tried to use it on the same program it has an error "Stack Overflow".

for people who don't know the difference between windows.forms.timer and system.timers.timer is windows.forms.timer can only be used on windows forms. surprised? hehehe

is there a difference on their behavior?
dapat hindi windows.Forms.Timer ang ginamit mo

try mo to
Code:
Public Class TimerClas
    Dim cTime As New Timer

    Friend Sub New(ByVal Interval As Long)
        cTime.Interval = Interval
        AddHandler cTime.Tick, AddressOf TimerEvent
    End Sub

    Friend Sub TimerStart()
        cTime.Start()
    End Sub

    Friend Sub TimerStop()
        cTime.Stop()
    End Sub

    Friend ReadOnly Property TimeElapsed() As Integer
        Get
            Dim nElapsed As Integer
            Return nElapsed
        End Get
    End Property

    Private Sub TimerEvent()
        'dito mag TICK ang timer

    End Sub
End Class



Give a man a computer program and you give him a headache,
but teach him to program computers and you give him the power to create headaches for others for the rest of his life..
VB.NET Programming Corner
VB6/MSAccess Using ADO with DataReport
Facebook, Other Threads
Join my shared folder in Dropbox get access to code samples, ebooks, tools and other usefull stuff
Reply With Quote
  #16  
Old 21st Jun 2010 Mon, 14:18
doorbreaker's Avatar
doorbreaker Male doorbreaker is offline
Forum Advisor
 
Join Date: Mar 2010
Location: earth
Posts: 909
Reputation: doorbreaker is an unknown quantity at this point
Default Re: VB.NET Programming Corner!

Quote:
Originally Posted by ericgmejia View Post
dapat hindi windows.Forms.Timer ang ginamit mo

try mo to
Code:
Public Class TimerClas
    Dim cTime As New Timer

    Friend Sub New(ByVal Interval As Long)
        cTime.Interval = Interval
        AddHandler cTime.Tick, AddressOf TimerEvent
    End Sub

    Friend Sub TimerStart()
        cTime.Start()
    End Sub

    Friend Sub TimerStop()
        cTime.Stop()
    End Sub

    Friend ReadOnly Property TimeElapsed() As Integer
        Get
            Dim nElapsed As Integer
            Return nElapsed
        End Get
    End Property

    Private Sub TimerEvent()
        'dito mag TICK ang timer

    End Sub
End Class
ito po code ko
Code:
public ctimer as system.timers.timer
sub new()

AddHandler ctimer.Elapsed, AddressOf DOSOMETHING()
ctimer.interval = 1000
ctimer.start
end sub

private sub DOSOMETHING
 'something
end sub

san po kinuha ung timer nyo? ang alam ko lang po kasi

windows.forms.timer
system.timers.timer
threading.timer




Last edited by doorbreaker; 21st Jun 2010 Mon at 14:19..
Reply With Quote
  #17  
Old 21st Jun 2010 Mon, 14:39
ericgmejia's Avatar
ericgmejia Male ericgmejia is online now
The Legend
 
Join Date: Dec 2007
Location: Makati City
Posts: 6,567
Reputation: ericgmejia will become famous soon enough
Default Re: VB.NET Programming Corner!

Quote:
Originally Posted by doorbreaker View Post
ito po code ko
Code:
public ctimer as system.timers.timer
sub new()

AddHandler ctimer.Elapsed, AddressOf DOSOMETHING()
ctimer.interval = 1000
ctimer.start
end sub

private sub DOSOMETHING
 'something
end sub

san po kinuha ung timer nyo? ang alam ko lang po kasi

windows.forms.timer
system.timers.timer
threading.timer

Forms.Timer yan, gumagamit ng Tick e

eto try mo mas ok

Code:
Imports System
Imports System.Timers

Public Class Timer1

    Private xTimer As System.Timers.Timer

    Public Shared Sub Main()
        ' Create a timer with a ten second interval.
        xTimer = New System.Timers.Timer(10000)

        ' Hook up the Elapsed event for the timer.
        AddHandler xTimer.Elapsed, AddressOf OnTimerEvent

        ' Set the Interval to 2 seconds (2000 milliseconds).
        xTimer.Interval = 2000
        xTimer.Enabled = True

        Console.WriteLine("Press the Enter key to exit the program.")
        Console.ReadLine()
xTimer.AutoReset
   End Sub

    ' Specify what you want to happen when the Elapsed event is 
    ' raised.
    Private Shared Sub OnTimerEvent(source As Object, e As ElapsedEventArgs)
        Console.WriteLine("The Elapsed event was raised at {0}", e.SignalTime)
    End Sub
End Class

'Output:
'
'Press the Enter key to exit the program.
'The Elapsed event was raised at 5/20/1900 8:42:27 PM
'The Elapsed event was raised at 5/20/1900 8:42:29 PM
'The Elapsed event was raised at 5/20/1900 8:42:31 PM
'...



Give a man a computer program and you give him a headache,
but teach him to program computers and you give him the power to create headaches for others for the rest of his life..
VB.NET Programming Corner
VB6/MSAccess Using ADO with DataReport
Facebook, Other Threads
Join my shared folder in Dropbox get access to code samples, ebooks, tools and other usefull stuff

Last edited by ericgmejia; 21st Jun 2010 Mon at 14:48..
Reply With Quote
  #18  
Old 21st Jun 2010 Mon, 15:48
doorbreaker's Avatar
doorbreaker Male doorbreaker is offline
Forum Advisor
 
Join Date: Mar 2010
Location: earth
Posts: 909
Reputation: doorbreaker is an unknown quantity at this point
Default Re: VB.NET Programming Corner!

Quote:
Originally Posted by ericgmejia View Post
Forms.Timer yan, gumagamit ng Tick e

eto try mo mas ok

Code:
Imports System
Imports System.Timers

Public Class Timer1

    Private xTimer As System.Timers.Timer

    Public Shared Sub Main()
        ' Create a timer with a ten second interval.
        xTimer = New System.Timers.Timer(10000)

        ' Hook up the Elapsed event for the timer.
        AddHandler xTimer.Elapsed, AddressOf OnTimerEvent

        ' Set the Interval to 2 seconds (2000 milliseconds).
        xTimer.Interval = 2000
        xTimer.Enabled = True

        Console.WriteLine("Press the Enter key to exit the program.")
        Console.ReadLine()
xTimer.AutoReset
   End Sub

    ' Specify what you want to happen when the Elapsed event is 
    ' raised.
    Private Shared Sub OnTimerEvent(source As Object, e As ElapsedEventArgs)
        Console.WriteLine("The Elapsed event was raised at {0}", e.SignalTime)
    End Sub
End Class

'Output:
'
'Press the Enter key to exit the program.
'The Elapsed event was raised at 5/20/1900 8:42:27 PM
'The Elapsed event was raised at 5/20/1900 8:42:29 PM
'The Elapsed event was raised at 5/20/1900 8:42:31 PM
'...


i think na solve ko na po problem ko. sana you can support me sa observation ko. ganto po un

windows.forms.timers inaantay nya matapos ung buong procedure na nkalagay sa tick event nya before mag trigger ulit incase na hindi pa tapos ang event eh tapos na interval.

system.timers.timer trigger ng trigger ang events based on interval kahit na hindi pa tapos ang procedures.

tama po ba observation ko?



Reply With Quote
  #19  
Old 21st Jun 2010 Mon, 16:01
ericgmejia's Avatar
ericgmejia Male ericgmejia is online now
The Legend
 
Join Date: Dec 2007
Location: Makati City
Posts: 6,567
Reputation: ericgmejia will become famous soon enough
Default Re: VB.NET Programming Corner!

Quote:
Originally Posted by doorbreaker View Post
i think na solve ko na po problem ko. sana you can support me sa observation ko. ganto po un

windows.forms.timers inaantay nya matapos ung buong procedure na nkalagay sa tick event nya before mag trigger ulit incase na hindi pa tapos ang event eh tapos na interval.

system.timers.timer trigger ng trigger ang events based on interval kahit na hindi pa tapos ang procedures.

tama po ba observation ko?
tama, asynchronous ang timer, supposed to be
pero nasa same thread sila ng task mo,

Quote:
The System.Windows.Forms.Timer runs on the same thread as the application.
So if your application is carrying out some processor-intensive task, the
timer ticks are not going to be fired since the thread is busy doing your
task. Instead, use the System.Timers.Timer (which runs on a seperate thread
than the application) and write your code in the Elapsed event of the timer.
pag System.Timers;
mag tick ulit yan basta inabutan ng interval, walang pakialam kung may ginagawa pa sa loob ng tick event.

kung gusto mo tapusin yung task, i stop/disable mo muna yung timer, then after ng task, saka ka mag start/enable ulit para synchronized



Give a man a computer program and you give him a headache,
but teach him to program computers and you give him the power to create headaches for others for the rest of his life..
VB.NET Programming Corner
VB6/MSAccess Using ADO with DataReport
Facebook, Other Threads
Join my shared folder in Dropbox get access to code samples, ebooks, tools and other usefull stuff

Last edited by ericgmejia; 21st Jun 2010 Mon at 16:27..
Reply With Quote
  #20  
Old 21st Jun 2010 Mon, 16:13
doorbreaker's Avatar
doorbreaker Male doorbreaker is offline
Forum Advisor
 
Join Date: Mar 2010
Location: earth
Posts: 909
Reputation: doorbreaker is an unknown quantity at this point
Default Re: VB.NET Programming Corner!

Quote:
Originally Posted by ericgmejia View Post
tama, asynchronous ang timer

mag tick ulit yan basta inabutan ng interval, walang pakialam kung may ginagawa pa sa loob ng tick event.

kung gusto mo tapusin yung task, i stop/disable mo muna yung timer, then after ng task, saka ka mag start/enable ulit
thanks po ok na prob ko.



Reply With Quote
Reply

Thread Tools

Forum Jump


All times are GMT +8. The time now is 15:42.