Avatar of Scripter25
Scripter25

asked on 

DetailsView Multiple Table Insert

I am using ASP.NET DetailsView I am wanting to insert into  multiple tables with the one Insert from the Detailsview can someone please shed some light on this one for me?
Microsoft SQL Server 2005ASP.NET

Avatar of undefined
Last Comment
xiong8086
Avatar of codeclay
codeclay
Flag of India image

Avatar of Lowfatspread
Lowfatspread
Flag of United Kingdom of Great Britain and Northern Ireland image

consider creating a view for the data ...
then have and instead of trigger on the view to handle you updates into the
individual base tables...
Avatar of Scripter25
Scripter25

ASKER

CREATE PROCEDURE dbo.Deposit

DECLARE @CheckAvailable money, @CheckBalance money, @Checking bit, @EnteredAmount smallmoney

EXECUTE dbo.GetLastValueChecking  
    @CheckAvailable OUTPUT,
    @CheckBalance OUTPUT
IF @Checking =1
BEGIN
      INSERT INTO Checking (Balance,Available)Values(@CheckBalance,@CheckAvailable)
END
ELSE
    PRINT 'Do Something.'
Avatar of Scripter25
Scripter25

ASKER

I tried doing this but it says syntax error near execute
Avatar of Scripter25
Scripter25

ASKER

sorry take that back it says Syntax Error near Declare
Avatar of Scripter25
Scripter25

ASKER

Look maybe this will help if I state this info first of all... I am trying to make a financial tracking site. when I enter in deposits I need to add that amount to the current balance.
Avatar of Scripter25
Scripter25

ASKER

Ok I have come up with a possible new solution instead of keeping my info in separate tables I can just add them together right away but if I do then I still need to be able to pull the value of the last Balance before adding it to my deposit to make the new balance insert.

Primary Key       smallmoney       smallmoney       datetime
ID       Balance       Available       date

I am using a DetailsView in Insertmode to try to accomplish this. Is this even possible?
Avatar of Lowfatspread
Lowfatspread
Flag of United Kingdom of Great Britain and Northern Ireland image

CREATE PROCEDURE dbo.Deposit
 @CheckAvailable money
, @CheckBalance money
, @Checking bit
, @EnteredAmount smallmoney

as

SET NOCOUNT ON

EXECUTE dbo.GetLastValueChecking  -- need account or customerid????
    @CheckAvailable OUTPUT,
    @CheckBalance OUTPUT

IF @Checking =1
BEGIN
      INSERT INTO Checking (Balance,Available)Values(@CheckBalance,@CheckAvailable)
END
ELSE
    PRINT 'Do Something.'


RETURN
GO


Avatar of Scripter25
Scripter25

ASKER

error procedure or function "deposit" has to many arguments specified  


any ideas on that one?
ASKER CERTIFIED SOLUTION
Avatar of xiong8086
xiong8086

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
ASP.NET
ASP.NET

The successor to Active Server Pages, ASP.NET websites utilize the .NET framework to produce dynamic, data and content-driven web applications and services. ASP.NET code can be written using any .NET supported language. As of 2009, ASP.NET can also apply the Model-View-Controller (MVC) pattern to web applications

128K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo