<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>SQL Server, SQL Server Express, and SqlDataSource Control</title><link>http://forums.asp.net/54.aspx</link><description>All about SQL Server, SQL Server Express, MSDE, and the SqlDataSource control.</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Re: Insert Data with Parameter of SQL Query</title><link>http://forums.asp.net/thread/3216419.aspx</link><pubDate>Sun, 07 Jun 2009 21:45:45 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3216419</guid><dc:creator>Naom</dc:creator><author>Naom</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3216419.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=54&amp;PostID=3216419</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;create procedure usp_InsertIntoMyTable(@Va1 as varchar(100), @Val2 as int, etc., OUT @Max_Recipe int) as&lt;/p&gt;&lt;p&gt;BEGIN&lt;/p&gt;&lt;p&gt;select @Max_Recipe = max(ID) from myTable where some condition&lt;/p&gt;&lt;p&gt;insert into myTable (...)&lt;/p&gt;&lt;p&gt;END&lt;/p&gt;&lt;p&gt;And then use SP instead of direct command. &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: Insert Data with Parameter of SQL Query</title><link>http://forums.asp.net/thread/3216414.aspx</link><pubDate>Sun, 07 Jun 2009 21:38:52 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3216414</guid><dc:creator>tmk8789</dc:creator><author>tmk8789</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3216414.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=54&amp;PostID=3216414</wfw:commentRss><description>Naom,

Thanks for the quick reply.

1.  I&amp;#39;m not trying to simulate the identity field from that table.  The query actually returns the max id for the logged in user so it&amp;#39;s not the literal max id from the table.

2.  I&amp;#39;ve seen this as an option in other posts too, but I&amp;#39;m not too familiar with how to accomplish this.  Could you help me with a starting point; then I can tweak it from there.

Thanks again!</description></item><item><title>Re: Insert Data with Parameter of SQL Query</title><link>http://forums.asp.net/thread/3216400.aspx</link><pubDate>Sun, 07 Jun 2009 21:28:54 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3216400</guid><dc:creator>Naom</dc:creator><author>Naom</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3216400.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=54&amp;PostID=3216400</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;1. Why do you need to use max value ? Are you trying to simulate Identity field?&lt;/p&gt;&lt;p&gt;2. I suggest to simply put the logic into the stored procedure to both get the maximum value and insert as one operation. You can return the max value (inserted value) as the output parameter. &lt;br /&gt;&lt;/p&gt;</description></item><item><title>Insert Data with Parameter of SQL Query</title><link>http://forums.asp.net/thread/3216384.aspx</link><pubDate>Sun, 07 Jun 2009 21:12:08 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3216384</guid><dc:creator>tmk8789</dc:creator><author>tmk8789</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3216384.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=54&amp;PostID=3216384</wfw:commentRss><description>Hi all,

I&amp;#39;m new to ASP.net and and using Visual Studio 2008 and VB as my source code.  I would like to query a database for a value (guaranteed to return 1 row 1 column (SELECT MAX(RECIPE_ID FROM TB_RECIPE) and then insert this value as part of another insert statement (INSERT INTO [TB_INGREDIENTS] ([RECIPE_ID], [OWNER_ID], [INGREDIENT_NAME], [QUANTITY], [UNIT_OF_MEASURE]) VALUES (@RecipeID, @UserID, @INGREDIENT_NAME, @QUANTITY, @UNIT_OF_MEASURE)) where the Recipe ID obtained in the first query is the parameter sent in the insert statement as @RecipeID.

I&amp;#39;m using SQL Server 2005 Express connecting to an attached .mdf file.

I think based on my research so far on this site that I need to use a scalar variable, but I&amp;#39;m too new to this to know how to accomplish this.  Any help would be greatly appreciated....</description></item></channel></rss>