Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Basic Calculations in a Database

Author  Topic 

DianeJ
Starting Member

6 Posts

Posted - 2007-01-17 : 15:47:47
I am trying to write a small program to keep track of my bank accounts using Visual Basic Express and Sql databases. My database has the usual expected columns in my table - deposit, withdraw and Balance. I am displaying this infor on my form in Datagrid view. My problem is I have no Idea how to get it to to the necessary calculations. I.e. if I enter an amount in the deposit or withdrawel column I want it to automatically update the balance column.

I have no Idea how to do this, where to code it or anything so some help for a newbie (in as simple steps as possible) would be really really appreciated. Since my program is useless without this bit working

Diane

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-01-17 : 16:08:43
you'd need to use an after insert/update/delete trigger.



Go with the flow & have fun! Else fight the flow
blog thingie: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

DianeJ
Starting Member

6 Posts

Posted - 2007-01-17 : 16:25:13
Im sorry Spirit1, as I said I am really new to this and do not how or where to do this.
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-01-17 : 16:32:20
what kind of sql database are you using?
access, sql express or something else?




Go with the flow & have fun! Else fight the flow
blog thingie: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

DianeJ
Starting Member

6 Posts

Posted - 2007-01-17 : 16:36:32
Hi Spirit1. I am Using SQL Express.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-01-17 : 16:43:23
I would not use triggers for these since the columns are in the same table. I'd setup the balance as a computed column. For information on computed columns, see CREATE TABLE topic in SQL Server Books Online.

Tara Kizer
Go to Top of Page

DianeJ
Starting Member

6 Posts

Posted - 2007-01-17 : 17:07:38
Thanks for the suggestion Tara. I am downloading a new version of this now. Hopefully it will be easier to understand than a lot of the stuff on the microsoft website/library.
quote:
Originally posted by tkizer

I would not use triggers for these since the columns are in the same table. I'd setup the balance as a computed column. For information on computed columns, see CREATE TABLE topic in SQL Server Books Online.

Tara Kizer

Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-01-18 : 01:42:26
Topic continued and answered here
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=77715


Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -