Forums
This topic is locked
Insert data in table from stored procedure
05 Sep 2006 15:58:18 Iv Sce posted:
Here is Dreamweaver Insert record code that I use<MM<img src=../images/dmxzone/forum/icon_smile_blush.gif border=0 align=middle>nsert
runat="server"
CommandText='<%# "INSERT INTO dbo.zbir (zbir, proizvod) VALUES (@zbir, @proizvod)" %>'
ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_STRING_Konekcija" %>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_DATABASETYPE_Konekcija" %>'
CreateDataSet="false"
Debug="true"
>
<Parameters>
<Parameter Name="@zbir" Value='<%# GetCeneFromProizvodi.FieldValue("Price", Container) %>' Type="decimal" />
<Parameter Name="@proizvod" Value='<%# GetCeneFromProizvodi.FieldValue("Naziv", Container) %>' Type="VarChar" />
</Parameters>
</MM<img src=../images/dmxzone/forum/icon_smile_blush.gif border=0 align=middle>nsert>
Code is executed every time when page loads. There is no form button.
Under "Value" is my default value for parameters @zbir and @proizvod. I get it from DataSet called "GetCeneFromProizvodi". I also have stored procedure called "GetArtikalPriceCheckerMK". How can I insert data from my stored procedure (parameters are same, "Price" and "Naziv" and not from DataSet? Should I create another DataSet for stored procedure? Or else...?
Thanks alot!
Replies
Replied 07 Sep 2006 15:37:07
07 Sep 2006 15:37:07 Dmitry Belov replied:
You have to use Function instead of Stored procedure.
like this :
INSERT INTO dbo.zbir (zbir, proizvod) select zbir, proizvod from FGetArtikalPriceCheckerMK(<price>,<Naziv><img src=../images/dmxzone/forum/icon_smile_wink.gif border=0 align=middle>
where FGetArtikalPriceCheckerMK(price,Naziv) is Function defined like
CREATE FUNCTION FGetArtikalPriceCheckerMK( price money, naziv varchar(xxx) )
RETURNS @retValue
TABLE (zbir <Your type>, proizvod <Your type><img src=../images/dmxzone/forum/icon_smile_wink.gif border=0 align=middle>
as begin
<BODY where you populate table @retValue >
end
like this :
INSERT INTO dbo.zbir (zbir, proizvod) select zbir, proizvod from FGetArtikalPriceCheckerMK(<price>,<Naziv><img src=../images/dmxzone/forum/icon_smile_wink.gif border=0 align=middle>
where FGetArtikalPriceCheckerMK(price,Naziv) is Function defined like
CREATE FUNCTION FGetArtikalPriceCheckerMK( price money, naziv varchar(xxx) )
RETURNS @retValue
TABLE (zbir <Your type>, proizvod <Your type><img src=../images/dmxzone/forum/icon_smile_wink.gif border=0 align=middle>
as begin
<BODY where you populate table @retValue >
end