Forums

ASP

This topic is locked

Insert data in table from stored procedure

Posted 05 Sep 2006 15:58:18
1
has voted
05 Sep 2006 15:58:18 Iv Sce posted:
Here is Dreamweaver Insert record code that I use

&lt;MM<img src=../images/dmxzone/forum/icon_smile_blush.gif border=0 align=middle>nsert
runat="server"
CommandText='&lt;%# "INSERT INTO dbo.zbir (zbir, proizvod) VALUES (@zbir, @proizvod)" %&gt;'
ConnectionString='&lt;%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_STRING_Konekcija" %&gt;'
DatabaseType='&lt;%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_DATABASETYPE_Konekcija" %&gt;'
CreateDataSet="false"
Debug="true"
&gt;
&lt;Parameters&gt;
&lt;Parameter Name="@zbir" Value='&lt;%# GetCeneFromProizvodi.FieldValue("Price", Container) %&gt;' Type="decimal" /&gt;
&lt;Parameter Name="@proizvod" Value='&lt;%# GetCeneFromProizvodi.FieldValue("Naziv", Container) %&gt;' Type="VarChar" /&gt;
&lt;/Parameters&gt;
&lt;/MM<img src=../images/dmxzone/forum/icon_smile_blush.gif border=0 align=middle>nsert&gt;

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(&lt;price&gt;,&lt;Naziv&gt<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 &lt;Your type&gt;, proizvod &lt;Your type&gt<img src=../images/dmxzone/forum/icon_smile_wink.gif border=0 align=middle>
as begin

&lt;BODY where you populate table @retValue &gt;

end




Reply to this topic