|
-
Jun 28th, 2009, 01:12 AM
#1
Thread Starter
Junior Member
how to minus an integer from database (from columns in 2 table) in vb2005 ?
-in my database..there are 2 tables..
1)Leave_application
2)Staff
-how do i type the code to minus out the number from "Leave_balance" (in the Staff table) with the number from "Days_apply" (in Leave_application table)
eg: 10 days (from "Leave_balance" Staff_ID "S0001") - 2 days (from "Days_apply" ID "abc") = 8 days
- and then update the "Leave_balance" of staff_ID "S0001" with 8 days
can someone help??
Last edited by wongth7; Jun 29th, 2009 at 12:22 AM.
-
Jun 28th, 2009, 02:20 AM
#2
Re: how to minus an integer from database (from columns in 2 table) in vb2005 ?
It would be a very simple update query.
I could tell you the exact syntax if you really want me to, but it would be a better idea for you to take a look at the W3C Schools tutorials on SQL as it will help unlock the power of databases for you and it will only take a few moments for you to work out the exact query you need.
-
Jun 29th, 2009, 12:20 AM
#3
Thread Starter
Junior Member
Re: how to minus an integer from database (from columns in 2 table) in vb2005 ?
 Originally Posted by keystone_paul
It would be a very simple update query.
I could tell you the exact syntax if you really want me to, but it would be a better idea for you to take a look at the W3C Schools tutorials on SQL as it will help unlock the power of databases for you and it will only take a few moments for you to work out the exact query you need.
after viewing the page u gave,..i still dont have any idea how to use it in my vb codings..can give explain more details bout it??
or anyone out there can help??
________________________________________
ok, i will explain my question clearer here
- Leave "abc" is applied by staff "S0001" for 2 days
so what i want to ask is how to minus the 2 days from his Leave_balance of 10 days....and then save the new leave balance (8 days) in staff s0001 "Leave_balance" column.
Last edited by wongth7; Jun 29th, 2009 at 12:27 AM.
-
Jun 29th, 2009, 01:49 AM
#4
Re: how to minus an integer from database (from columns in 2 table) in vb2005 ?
You need to formulate the SQL query using the syntax explained in that tutorial.
You havent given any information at all about how you are accessing your database within your own code, but assuming that you are using ADO.Net you can create a command object, set its commandtext to your SQL and then call its ExecuteNonQuery method.
If thats all greek to you then in addition to the SQL tutorial you will need to look up a good ADO.Net tutorial as well. There's a basic intro to using ADO.Net with Access here or jmcilhinney has written an introduction in the Codebank.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|