Showing posts with label retrieving. Show all posts
Showing posts with label retrieving. Show all posts

Friday, March 23, 2012

Saving Data and retrieving it from the database

Heres my requirement from a financial analysis im doing...

I have just calculated an industry averages on financial ratios...Now i wanna upload this industry average to the system...so that I can compare it to the individual companies' averages after calculating a particular company's average; meaning i wanna be able to call the industry average of a particular ratio (eg Current Ratio) after calculating a company's corresponding ratio...Is there a code fragment i can use for this ??

Thanks in advance...

Adam

Hi,

From your description, it seems that you are going to retrieve the industry averages which you stored in database after calculating particular company's averages, right?

I think the code should be based on the data structure. I don't know how do you handle with your data storage in your project? Does each company's average data stored in a table? Where does the industry average data comes from? It comes from manually calculating? If so, what you should do is just save the data into a single data table, when you are going to calculate each company's average, retrieve the data from your database and save it in a seesion or viewstate to avoid reading the value from database frequently.

Above is just the general idea for your question, as for detail code, it depends on what kinds of way you are going to use, SqlDataReader, Dataset and etc… But the usage of this kinds of data accessing technique can be found at the following address.
http://quickstarts.asp.net/QuickStartv20/aspnet/doc/data/default.aspx

Thanks.

sql

Saving and retrieving older quotes

I am redesigning a database that had some serious problems. I've resolved
most of the issues except one: retrieving previous quotes.
The program that uses this database is a pricing program for a
custom-configured item. Thus, the cost of a particular end item is based on
a variety of other items and also on a variety of what I call "pricing
methods", i.e., by the sq. ft, by the unit, etc.. Cost is further based on
such factors as a manufacturer's multiplier, markup, and sales tax.
Over time, these items that make up the cost of this custom-configured item
may obviously change, sales tax may go up, the manufacturer may want more,
the labor rate may change, and so forth. Further, the pricing method may
change.
Yet we may often retrieve previous quotes. Those quotes may be from
yesterday, or from 2 years ago. So we will need to know what the calculated
values WERE, not what they would be if recalculated today.
It's simplistic enough to pass the caveat "don't store calculated values".
But this is simply unacceptable dogma in this situation -- we WILL save
calculated values. The question becomes "how".
You will notice in the table below some of the cost items, there are
actually another 30 or so discrete items that make up each product. Most of
those 30 or so items have a "pricing method" in the lookup table that will
determine how the item gets priced (example in the 2nd table shown).
My main concern is how to save the pricing method for EACH of these costs in
the JobCosts table. It's clearly not in 3N form to have a
"ColorCostPricingMethod" field, a "HardwareCostPricingMethod" field, and so
forth. Any advice on fixing this structure or a pointer to a relevant book
or online resource would be helpful (I have Louis Davidson's excellent book,
but it is not precisely on point).
CREATE TABLE [dbo].[JobCosts] (
[CostID] [int] NOT NULL ,
[MeasureID] [int] NULL ,
[LastRevisedDate] [smalldatetime] NULL ,
[MfrMultiUsed] [float] NULL ,
[TaxPercentUsed] [float] NULL ,
[SalesTaxUsed] [float] NULL ,
[OurMarkupUsed] [float] NULL ,
[ModelCost] [float] NULL ,
[ColorCost] [float] NULL ,
[HardwareCost] [int] NULL ,
[LaborCost] [int] NULL ,
[BaseItemCost] [float] NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[HardwareFinishCosts] (
[ItemListID] [int] NULL ,
[HardwareFinishID] [int] NULL ,
[MaximumWidth] [int] NULL ,
[Cost] [float] NULL ,
[PricingMethod] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GOsame objects with different attributes are different entities.
object1 with price 20 is different from
object1 with price 30
therefore each object must have different primary keys
it will look like a fact table in the Warehouse database
thanks,
Jose de Jesus Jr. Mcp,Mcdba
Data Architect
Sykes Asia (Manila philippines)
MCP #2324787
"Earl" wrote:

> I am redesigning a database that had some serious problems. I've resolved
> most of the issues except one: retrieving previous quotes.
> The program that uses this database is a pricing program for a
> custom-configured item. Thus, the cost of a particular end item is based o
n
> a variety of other items and also on a variety of what I call "pricing
> methods", i.e., by the sq. ft, by the unit, etc.. Cost is further based on
> such factors as a manufacturer's multiplier, markup, and sales tax.
> Over time, these items that make up the cost of this custom-configured ite
m
> may obviously change, sales tax may go up, the manufacturer may want more,
> the labor rate may change, and so forth. Further, the pricing method may
> change.
> Yet we may often retrieve previous quotes. Those quotes may be from
> yesterday, or from 2 years ago. So we will need to know what the calculate
d
> values WERE, not what they would be if recalculated today.
> It's simplistic enough to pass the caveat "don't store calculated values".
> But this is simply unacceptable dogma in this situation -- we WILL save
> calculated values. The question becomes "how".
> You will notice in the table below some of the cost items, there are
> actually another 30 or so discrete items that make up each product. Most o
f
> those 30 or so items have a "pricing method" in the lookup table that will
> determine how the item gets priced (example in the 2nd table shown).
> My main concern is how to save the pricing method for EACH of these costs
in
> the JobCosts table. It's clearly not in 3N form to have a
> "ColorCostPricingMethod" field, a "HardwareCostPricingMethod" field, and s
o
> forth. Any advice on fixing this structure or a pointer to a relevant book
> or online resource would be helpful (I have Louis Davidson's excellent boo
k,
> but it is not precisely on point).
> CREATE TABLE [dbo].[JobCosts] (
> [CostID] [int] NOT NULL ,
> [MeasureID] [int] NULL ,
> [LastRevisedDate] [smalldatetime] NULL ,
> [MfrMultiUsed] [float] NULL ,
> [TaxPercentUsed] [float] NULL ,
> [SalesTaxUsed] [float] NULL ,
> [OurMarkupUsed] [float] NULL ,
> [ModelCost] [float] NULL ,
> [ColorCost] [float] NULL ,
> [HardwareCost] [int] NULL ,
> [LaborCost] [int] NULL ,
> [BaseItemCost] [float] NULL
> ) ON [PRIMARY]
> GO
> CREATE TABLE [dbo].[HardwareFinishCosts] (
> [ItemListID] [int] NULL ,
> [HardwareFinishID] [int] NULL ,
> [MaximumWidth] [int] NULL ,
> [Cost] [float] NULL ,
> [PricingMethod] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
> ) ON [PRIMARY]
> GO
>
>
>
>|||> same objects with different attributes are different entities.
> object1 with price 20 is different from
> object1 with price 30
> therefore each object must have different primary keys
> it will look like a fact table in the Warehouse database
I'd also suggest giving each entity a time context, an
ActiveSince/ActiveUntil datetime range. Consider whether these ranges should
be allowed to overlap. Would it make sense to allow "object1 with price 20"
and "object1 with price 30" be active at the same time? (Depends on the
actual requirements.)
ML

Saving and Retrieving Binary Files in MSSQL 2005

Dear all,
Can any one provide me a sample source regarding saving and retrieving
binary files in MSSQL 2005. I have try it but I found that it only insert
the first element of that byte array that I read from file to table.
I was using Microsoft Data Access Application Block version 2 SQLhelper
to done the execution portion.
ThanksHi
The text, ntext and image data types have successors: varbinary(max),
varchar(max) and nvarchar(max).
Those can be addressed like normal char and binary columns, no need to chunk
the data in.
Application Blocks 2 don't support he new datatypes as it is still a .NET
1.1 application.
Regards
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"Goh" <goh@.noemail.noemail> wrote in message
news:utOmXEv%23FHA.2036@.TK2MSFTNGP14.phx.gbl...
> Dear all,
> Can any one provide me a sample source regarding saving and retrieving
> binary files in MSSQL 2005. I have try it but I found that it only insert
> the first element of that byte array that I read from file to table.
> I was using Microsoft Data Access Application Block version 2 SQLhelper
> to done the execution portion.
> Thanks
>
>|||Hello,
Did you try this code?
byte[] mmfbBlob;
SqlParameter Parameter1 = new SqlParameter("@.mmfbBlobThumb",
SqlDbType.Image);
Parameter1.Value = mmfbBlob;
Since the issue is related ADO.net, my suggestion is that you go there
since you could obtain most qualified answers there:
microsoft.public.dotnet.framework.adonet
Best Regards,
Peter Yang
MCSE2000/2003, MCSA, MCDBA
Microsoft Online Partner Support
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
========================================
=============
This posting is provided "AS IS" with no warranties, and confers no rights.
--
>From: "Goh" <goh@.noemail.noemail>
>Subject: Saving and Retrieving Binary Files in MSSQL 2005
>Date: Wed, 7 Dec 2005 13:42:56 +0800
>Keywords: Saving and Retrieving Binary Files in MSSQL 2005
>Lines: 13
>X-Priority: 3
>X-MSMail-Priority: Normal
>X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
>X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
>X-RFC2646: Format=Flowed; Original
>Message-ID: <utOmXEv#FHA.2036@.TK2MSFTNGP14.phx.gbl>
>Newsgroups: microsoft.public.sqlserver.programming
>NNTP-Posting-Host: tm.net.my 60.49.6.190
>Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP14.phx.gbl
>Xref: TK2MSFTNGXA02.phx.gbl microsoft.public.sqlserver.programming:566803
>X-Tomcat-NG: microsoft.public.sqlserver.programming
>Dear all,
> Can any one provide me a sample source regarding saving and retrieving
>binary files in MSSQL 2005. I have try it but I found that it only insert
>the first element of that byte array that I read from file to table.
> I was using Microsoft Data Access Application Block version 2 SQLhelper
>to done the execution portion.
>Thanks
>
>|||http://spaces.msn.com/members/staceyw/Blog/cns!1pnsZpX0fPvDxLKC6rAAhLsQ!404.
entry
William Stacey [MVP]
"Goh" <goh@.noemail.noemail> wrote in message
news:utOmXEv%23FHA.2036@.TK2MSFTNGP14.phx.gbl...
> Dear all,
> Can any one provide me a sample source regarding saving and retrieving
> binary files in MSSQL 2005. I have try it but I found that it only insert
> the first element of that byte array that I read from file to table.
> I was using Microsoft Data Access Application Block version 2 SQLhelper
> to done the execution portion.
> Thanks
>
>