Basic Calculations In A Database
Jan 17, 2007
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
View 7 Replies
ADVERTISEMENT
Mar 27, 2006
Amanda writes "I'm a student currently taking a class working with the SQL database and I'm not doing too well in that class because I'm struggling on some basics. I have worksheets and everything i just need help working on them, and this being and on-line class makes it hard for me to work with my teacher. If someone is willing to work with me one on one through a messaging program or Email that would be great, i can send you the worksheets and we can work it out together."
View 5 Replies
View Related
Jan 28, 2008
Hi Can Anybody help me what exectly is database mirroring? I am working in a small scale company. we have SQL server 2005 installed for a software used by our staff. Can any body expalin me what is mirrroring? how can i implements to my Database? What are the Basic Requirements? What are the Steps? Plz.. Thanks in advace who ever help me out for this......
View 1 Replies
View Related
Jan 11, 2007
First i am newbie in vb and Sql server...
Is possible to create and attaching, via vb classic or VBA, a sql
database in this instance:\DVD377-14D9E48CSQLEXPRESS...
I have Sql Express.
Database name: mydatabase
Database Table: mytable
fileds:
fiedl1 text format
fiedl2 text format
fiedl3 text format
fiedl4 date format
fiedl5 number format
fiedl6 text format
View 2 Replies
View Related
Jan 11, 2007
First i am newbie in vb and Sql server...
Is possible to create and attaching, via vb classic or VBA, a sql
database in this instance:\DVD377-14D9E48CSQLEXPRESS...
I have Sql Express(msde).
Database name: mydatabase
Database Table: mytable
fileds:
fiedl1 text format
fiedl2 text format
fiedl3 text format
fiedl4 date format
fiedl5 number format
fiedl6 text format
View 3 Replies
View Related
Apr 21, 2008
Let me get VERY specific.
This site has 40+ pages Using VWD 2008 (Studio 2008)
I have created in local IIS7 (129.0.0.2) http://cumc.lcl
Navigation.master, Web.config and Web.sitemap alll are structured
And all 40+ pages have been built.
NOW I added (using VWD) a sql server database named pagedata.mdf
With a table named: pages
and fields:
PageID - Primary Key (auto numbered)
pagename - nchar(30) exmp Default
hitcount - numeric(18,0)
createdate - nchar(15) exmp 04/18/2008
updated - nchar(15) similar to createdate
hitdate - nchar(15) similar to createdate
bottom of each page is to show 99999 visitors
and under that is to be Updated on mm/dd/yyyy
On pageload should accomplish the following increment the hitcount
field and save it and display it in HitLabel.text
Set UpdateLabel.text to updated field
Save the date the page was hit in hitdate field. (will only show when last hit)
The "tester.aspx" page now has:
<%@ Page Language="VB" MasterPageFile="~/Navigation.master" Title="tester" %>
<script runat="server">
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
End Sub
</script>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"></asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<p align="center">This page is for various tests<br />and will NOT be site mapped.</p>
<p align="center"></p>
<p align="center">
Can this SqlDataSource be moved into Sub Page_load above?
How do I extract, process and save the Hit and Date data
for each individual page referenced by pagename field?
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStringsageConnect %>"
SelectCommand="SELECT * FROM [main] WHERE ([pagename] = @pagename)">
<SelectParameters>
<asp:QueryStringParameter Name="pagename" QueryStringField="thispage"
Type="String" />
</SelectParameters>
</asp:SqlDataSource>
</p>
<p align="center">
<asp:Label ID="HitLabel" runat="server"></asp:Label>
Visitors<br />
Updated on <asp:Label ID="UpdateLabel" runat="server"></asp:Label>
</p>
</asp:Content>
View 2 Replies
View Related
Jun 1, 2007
Admit have a txt file similar:
filed1 filed2
aaaaaaaaaa bbbbbbbbbbbbbb
cccccccccccc dddddddddddddd
.............
yyyyyyyyyy zzzzzzzzzzzzzz
How to create VIA VISUAL BASIC (ADO or DAO) a new SQL Server databse?
View 2 Replies
View Related
Aug 22, 2006
can i run such a transact SQL script with VB
use master
go
create database Ayhandeneme
on (Name=AyhanDeneme_Dat, FileName='c:ayhandeneme.mdf')
go
View 6 Replies
View Related
Dec 21, 2005
When you work with Visual Basic 2005 Express Edition on windows XP, and if your application contains references to SQL-databases, I have discovered that it is important that all identities be logged off before you open the particular identity where you want to work on your Visual Basic project. I have earlier assumed that it was only possible to work with Visual Basic on one identity, the one where the version was registered.
This assumption was not quite correct. Actually, you may run Visual Basic applications with SQL-references on all identities on XP, provided that no other identities that are using the SQL-server are currently running.
For example, suppose you start your computer and log on the identity James. Then you switch identity, but you actually don't log off James. Then you log on the John identity. There you discover that it is impossible to create a new SQL-database in Visual Basic's Data-connections view. An error message appears. Why is that? It is because the SQL-server is busy on the James-identity. To solve this problem you want to log off the John identity, don't just switch. Then log on the James identity again, and log off properly. All identities should now be logged off. Now you may log on the John identity again, and it is now possible to create an SQL database.
Concerning deploying applications for XP. This issue is similar to the one I just described. You cannot run the installation-file successfully on one identity if the SQL-sever is busy on another identity. You want to log off all identities before logging on the identity where you want to install the application. Same thing when you want to run the deployed application.
Question. Does this limitation exist only in the express-editions of Visual Studio 2005 as a drag on free-ware, or is it prevalent in commercial editions as well? I would like to know a little more about this before purchasing the standard or professional edition of Visual Studio 2005.
Best Regards
Ziper
View 7 Replies
View Related
Feb 17, 2007
Hi,
Can I upload a database using visual basic 05 express edition ? or do I have to download sql server ?
Thanks
View 8 Replies
View Related
Mar 24, 2008
What are the basic processes for maintaining an SQL SERVER 2005 Database?
Is there a top ten list of things you should do periodically to all SQL SERVER 2005 databases?
View 2 Replies
View Related
Mar 28, 2008
I have an application written with Visual Basic Express 2008, which has a Sql Server Express Compact database incorporated into the application. I've been trying to follow the suggestions listed on several threads on how to backup up my database and have not gotten very far. The following code seems to be in most threads.
Dim dbstring = "Data Source=.SQLExpress;Integrated Security=true;User Instance=true;AttachDBFilename=|DataDirectory|ImmuLogDataBase.sdf"
Dim sqlconn As New SqlClient.SqlConnection(dbstring)
sqlconn.Open()
When run, this code returns the following error at the sqlconn.Open() command.
An attempt to attach an auto-named database for file G:ImmuLogImmuLoginDebugImmuLogDataBase.sdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
My solution is saved on a flash drive which I take between home and work. I'm hoping that that isn't the issue. I believe that Visual Basic loads the database when it starts and it is already open when this code is run. Is there a way to access this open database and run a backup procedure on it from within VB express 2008?
I'm new to this and self taught so explain everything in detail. Thanks for your help.
Bruce
View 3 Replies
View Related
Oct 8, 2007
Hi, i am new to sql server and visual basic, i need to connect my sql server database to a new application i've developed in visual basic 2005 express. Can any one tell me the steps to do this. Many Thanks.
View 2 Replies
View Related
Apr 20, 2007
Hi everybody:
I go to Server Explorer, right click on Data Connection, input the server name (that is, my own computer), give a new name to the database to create, and then inevitably get the error window saying:
An error occurred while establishing a connection to the server. When connectiong to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL server does not allow remote connections. (Provider: Named Pipes Provider, error 40, could not open a conection to SQL Server)
So, how to open a connection to SQL server 2005? I looked in the msdn but found absolutely nothing.
Please help
Paolo
View 5 Replies
View Related
Sep 26, 2007
Code Snippet
Hi there,
I'm struggeling for more than a week now with this problem, without a finding the solution.
I have two databases, MS Access and SQL Server 2005 Express Edition
Using a procedure in Visual Studio i would like to copy all the records from one table in MS Access into an existing table in SQL Server (the tables have the same name and the same layout)
I tried to prepare one Dataset to copy from Access into SQL Server but when i run the command 'DaSQL.Update(DsSQL, "Tabella") nothing happens (not even an exeption has been raised), looking during debug, the DataSet seems filled though...
Please could anyone explain what's wrong and / or is there a more quicker way to copy data from a table to another?
Note i woul have as a final goal to get data from an AS400 database by ODBC, manage it, and put it on SQL Server for a 'data mining' scope (eliminating the use of MS Access, not suited for FE-BE).
the procedure goes like this;
' Create a connection to the MS Access Database
Dim connectionToAccess As New OleDbConnection(DBConnectionAccString)
strsql = "SELECT * FROM [TABELLA]"
connectionToAccess.Open()
Dim DaAccess As New OleDbDataAdapter(strsql, connectionToAccess)
Dim DsAccess As New DataSet("ACCESS")
DaAccess.FillSchema(DsAccess, SchemaType.Source, "Tabella")
DaAccess.Fill(DsAccess, "Tabella")
' Create a connection to the SQL Database
Dim connectionToSQL As New SqlConnection(DBConnectionSQLString)
connectionToSQL.Open()
Dim DaSQL As New SqlDataAdapter(strsql, connectionToSQL)
Dim DsSQL As New DataSet("SQL")
DaSQL.FillSchema(DsSQL, SchemaType.Source, "Tabella")
DaSQL.Fill(DsAccess, "Tabella")
DaSQL.Update(DsSQL, "Tabella")
Note I tried also the following, withou a result;
DsSQL = DsAccess.Copy
DaSQL.Update(DsSQL, "Tabella")
Please is there someone who could respond !!???
View 6 Replies
View Related
Jun 24, 2007
I am new to this type of programming and and have read all articles on adding an image to the database and it seems they all use sql queries to add an image but I want to add an image at design time. I am using Visual Basic 2005. I am also using Visual Basic 2005 Express Edition to try the same thing. I am trying to build a Translator program for english to Brazilian Portuguese and the reason I want to add the images is so that when I translate the word cat from english to Portuguese, I can also show an image of a cat. Can anyone please help me
View 3 Replies
View Related
May 18, 2007
Hello all. I am trying to do a calculation within an SQL script, however it doesnt seem to be working and i'm a little bit lost. If anyone could shed some light on where i'm going wring it would be much appreciated. The code I have is:
select
EMPLOYEE.EMPLOY_REF AS EDIT_REF,
SV_EMPLOYEE_CURRENT_HOLIDAY.ENTITLEMENT,
SV_EMPLOYEE_CURRENT_HOLIDAY.CARRIED_FWD,
SV_EMPLOYEE_CURRENT_HOLIDAY.TAKEN,
SV_EMPLOYEE_CURRENT_HOLIDAY.REMAINING,
SV_EMPLOYEE_CURRENT_HOLIDAY.SOLD,
SV_EMPLOYEE_CURRENT_HOLIDAY.PURCHASED,
SV_EMPLOYEE_CURRENT_HOLIDAY.ENTITLEMENT + SV_EMPLOYEE_CURRENT_HOLIDAY.SOLD - SV_EMPLOYEE_CURRENT_HOLIDAY.PURCHASED AS TOTAL_ENTITLEMENT
from
EMPLOYEE
left outer join
SV_EMPLOYEE_CURRENT_HOLIDAY
on
EMPLOYEE.EMPLOY_REF = SV_EMPLOYEE_CURRENT_HOLIDAY.EMPLOY_REF
where
EMPLOYEE.EMPLOY_REF = = 027
Incidentaly SV_EMPLOYEE_CURRENT_HOLIDAY is a view which currently exists.
Thanks in advance people.
View 2 Replies
View Related
Jul 1, 2007
In order to find out if an event is late or not I need to do some time calculations in SQL as a Stored procedure.
I have a DateTime variable called Due
I also have an Allowance variable which is an integer and is an extra allowance for that day and a third variable Now which is set with GETDATE()
If I compare Now to Due I can decide if the task is late or not - but I need to take itno account the Allowance.
I tried :
IF @Due + (@Allowance /24) < @Now ......
However I find that @Allowance/24 always equates to zero so this doesn't work.
I'd appreciate any advice.
Regards
Clive
View 2 Replies
View Related
Mar 21, 2008
Hello,
I ran into a little problem. My problem is: i need to substract 2 variabeles from 2 different tables in the database
TitleTimes left todayTimes left
My first excercise!15
My second excercise!19
The fields times left are a calculation... the number of times that the admin entered minus a count in the table scores.
Has anyone an idea how i can solve this?
An example excercise would be great!
Thanks in advance
View 5 Replies
View Related
Jun 5, 2008
I am attempting to construct a SELECT statement which incorporates some variables. The variables begin life as strings (not String objects) looking like :"6/08/2008" and "06/10/2008" for example. The first is a start date which was retrieved using an AJAX calendar object and the second is an end date retrieved in the same manner. My records are all timestamped by MS SQL (2003) including the clock time. I am stumbling on the syntax. "CallStartTime" is the record's timestamp. The "TraversalString" is something else but I am not attacking that yet. Can anyone make a suggestion or two?
SELECT count(*)FROM RealTime WHERE CallStartTime >= '@starttime' AND CallStartTime <= '@endtime' AND TraversalString LIKE '%1.0%'
View 2 Replies
View Related
Jun 5, 2006
Timespan = 30 days
Start Date = January 1st
Last Processed Day = NULL
Next Cycle Day = IF(Last Processed Day IS NULL) Start Date + TimeSpan ELSE Last Processed Day + TimeSpan
Is it possible to setup a column to do this from sql?
View 1 Replies
View Related
Jul 8, 2002
I have a timesheet table and I am having trouble getting a calculation to work correctly. I'd like to subtract the punch-in times from the punch out times for a specific period, such as 1 week, and then add the time together and get the number of minutes worked altogether during that time.
The table is simply
Employee ID (int)
PunchIn (datetime)
PunchOut (datetime)
Thanks for any help.
EL
View 2 Replies
View Related
Jan 4, 1999
I am trying to do a calculation to find rows which have a date which is 2 days older the the getdate().
i.e Select documentdate from table where documentdate < (getdate() - 2)
Any ideas on how I can perform this operation.
Thanks
Vinny
View 1 Replies
View Related
Mar 5, 2007
Hi,
I think that I want to want to build a temporary table in a stored procedure that handles multiple calculations.
I'll try and explain and hopefully you can tell me what i want
First i want to populate a list of all dealerstaff.
Code:
Select * From tblDealerstaff
I Then want to calculate the percentage tasks completed. So i find the number of available awards.
Code:
SELECT TOP (100) PERCENT COUNT(NoPerStaff) AS NoAwardsAvailable
FROM dbo.tblIndivAwards
Then i can find the number awards recieved per person.
Code:
SELECT TOP (100) PERCENT COUNT(dbo.tblIndivAwarded.AwardID) AS AwardCount
FROM dbo.tblIndivAwarded INNER JOIN dbo.tblIndivAwards ON dbo.tblIndivAwarded.IndivAwardID = dbo.tblIndivAwards.IndivAwardID
WHERE (dbo.tblIndivAwarded.staffID = @StaffID)
Trying to get my recordset to look like this >>
Fname + Lname + ((iNoAwarded / iNoAvailableAwards) * 100)
I want to know if it's possible to piece all of this calculation into a single stored procedure. I need to do this sort of thing all the time, as i display overviews of the projects i run to the senior managers.
I always do the maths in the ASP, and consequently i can't sort on the calulated totals.
Is this possible, or am i asking too much ?
Thanks in advance, as any help will be greatly recieved.
Regards,
Chris Brown
View 2 Replies
View Related
Jul 7, 2004
Hi
I sometimes find myself in the situation where I want to insert a row into a table using the following form:
insert table ( <field list> ) select <field list> from .. etc .. Where <conditions>
My question is to do with where one or more of the fields in the select field list are calculations and where I also want to use some/all of these derived fields as Where conditions. [ Eg: only insert if the calculated value is > 0]
I currently either repeat the calculation in the Where clause or move it to a function and use the function call in both places. (I always get a pang of guilt using either option - repeating the calculation feels like bad practice - & using the function twice seems inefficient (does this get optimised?)).
I could get a life & stop worrying - but is there a better/neater way of doing this?
Many thanks.
View 3 Replies
View Related
Aug 24, 2005
Vikram writes "Hi,
I need some help in date manipulations on SQL server data.
I am required to calculate to see
1. If anyone is absent one day within a 30 day period. if they are then upon their next absence in the same rolling 30 day period they need to be move to step I of disciplinary stage.
this information has to be checked for hundreds of employees.
I tried many ways but am not getting the right results. Moreover upon defaulting they will have to be moved to differnt steps.
Any suggestions will be greatly appreciated.
thanks in advance
Vik"
View 3 Replies
View Related
Nov 25, 2005
Hello,
I am a student and I have an assignment in for next week and we are having a few problems... below is some code we have created to enter in payment details for a customer....
INSERT into Payments values(Payments_seq.nextval, initcap('&Payment_Method'), '&Amount_Payable',
Date_Due = (select date_of_order from orders where order_no = (date_of_order+7));
I am having trouble with the last line, I want the date due to be calculated from the date the order was made in another table (orders) and I want a week to be added to this so that in the field it will display (date ordered plus 7 days)...
Any help you can give would be great, I've only been using isql plus for about 4 weeks...
Thanks
Pam :)
View 2 Replies
View Related
May 17, 2006
Users,
My question is about the number of calculation made with my database and my query.
The situation:
Table1: Contains 900 projects
Table2: Contains 13500 timesheets
Table3: Contains 516 Periods
Then there are 3 queries:
Query 1: Calculating the total for the periods
Query 2: Calculating working hours + working hours * total of a period
Query 3: Calculating loancosts of a project.
Query 3 is using 2 and 2 is using 1.
How many calculations are made in total????
Thanks!
Willio
View 4 Replies
View Related
Aug 10, 2006
Hello all.
I am looking to perform a calculation and enter the reult into a field within my table. The fields that I need to base the calculation on are all in one table (SALARY). The fields are: SALARY and BASIC_HOURS and the result is to be entered into field HOURLY_RATE. The actualy calculation to be preformed is:
hourly rate = ()salary / 52)/basic hours)
Thanks for reading :)
View 4 Replies
View Related
Mar 28, 2007
where should be the calculations be made based on performance, in SQL or in front end?
thanks.
-Ron-
View 7 Replies
View Related
Jul 23, 2005
Hi,I have a select query that returns three integer fields from a table thevalues range from 0 to 5. On each row I would like to calculate the averagevalue in the three fields however, the difficulty is that only the rowswhere the value is greater than 0 should be included in the calculation.To make this clearer please consider the following example:Col1 Col2 Col2 Average Calculation1 2 3 2 (Col1+Col2+Col3)/32 2 0 2 (Col1+Col2+Col3)/2The first row should be divided by 3 because each of the three columns has avalue greater than 0, however the second row should be divided by 2 becauseonly two of the value are greater than 0.Is this possible?Also is is possible to pass the results of one calculation into anothercalculation.Thanks in advance,Steve
View 3 Replies
View Related
Jul 20, 2005
hi,i ran the follow command:select #tempra.ranumber,#tempra.amountdue,#tempquickrec.t otalrec,#temparap.amountpaid,bal=amountdue - totalrec+amountpaidfrom #tempraleft join #tempquickrec on #tempquickrec.hrr = #tempra.ranumberleft join #temparap on #temparap.ranumber = #tempra.ranumberresult:ranumber amountdue totalrec amountpaid bal1222 $1200 $1000Null null2222 $3000 $3000 Null null3333$3000 $5000 $2000 0i know null is not zero thus bal column is null.this is because there is no corresponding record in the #temparap tableso how do i obtain the following result:(ie Ranumber bal is not 0)ranumber amountdue totalrec amountpaid bal1222 $1200 $1000Null 2002222 $3000 $3000 Null 03333 $3000$5000 $2000 0i am using ms sql2000thanks in advancerashid
View 2 Replies
View Related
Jul 20, 2005
I am looking to calculate the difference between and event time and a sampletime of Now. This is the query that I thought would do it, however I'mreturning DIFFERENCE values that look the same when the calcuation is beingmade on different EVENT_TIME values....I thought I knew how DateDiff worked, but apparently not.select GetDate()as NOW,event_time,Datediff(s,(Cast(event_time asNumeric)),(Cast(GetDate() as Numeric))) as DIFFERENCEFROM events-----------NOW----------|-----EVENT_TIME------|-DIFFERENCE2004-06-30 11:22:38.560 1999-10-30 23:51:37.000 1472256002004-06-30 11:22:38.560 1999-10-30 23:23:47.000 1472256002004-06-30 11:22:38.560 1999-10-30 06:49:38.000 1473120002004-06-30 11:22:38.560 1999-10-30 06:50:00.000 1473120002004-06-30 11:22:38.560 1999-10-30 06:50:41.000 1473120002004-06-30 11:22:38.560 1999-10-30 06:49:59.000 1473120002004-06-30 11:22:38.560 1999-10-30 06:49:58.000 1473120002004-06-30 11:22:38.560 1999-10-30 06:50:53.000 1473120002004-06-30 11:22:38.560 1999-10-30 06:50:46.000 1473120002004-06-30 11:22:38.560 1999-10-30 06:49:42.000 1473120002004-06-30 11:22:38.560 1999-10-30 06:50:36.000 1473120002004-06-30 11:22:38.560 1999-10-30 06:50:07.000 1473120002004-06-30 11:22:38.560 1999-10-30 10:54:37.000 1473120002004-06-30 11:22:38.560 1999-10-30 11:40:15.000 1473120002004-06-30 11:22:38.560 1999-10-30 09:52:51.000 1473120002004-06-30 11:22:38.560 1999-10-30 12:12:46.000 1472256002004-06-30 11:22:38.560 1999-10-30 12:32:45.000 1472256002004-06-30 11:22:38.560 1999-10-30 12:32:45.000 1472256002004-06-30 11:22:38.560 1999-10-30 12:32:46.000 1472256002004-06-30 11:22:38.560 1999-10-30 12:46:30.000 1472256002004-06-30 11:22:38.560 1999-10-30 15:31:25.000 1472256002004-06-30 11:22:38.560 1999-10-30 23:08:25.000 1472256002004-06-30 11:22:38.560 1999-10-30 16:35:51.000 147225600Can someone help?TIA!Joe..
View 2 Replies
View Related