INSERT INTO visit_table
SELECT Top 1 @Date, id
FROM id_table WHERE name = @NameBoxText
That is the SQL Server side. You will have to supply the values for @Date
and @NameBoxText. You have a choice to do this as a stored procedure or
inline SQL.
--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
*********************************************
Think outside the box!
*********************************************
[quoted text, click to view] "Dave" <davecove@gmail.com> wrote in message
news:1174713869.413910.101630@p15g2000hsd.googlegroups.com...
> Let's say that you wanted to perform an INSERT, but that one of the
> values in the insert had to be selected from another table based on
> the text property of a TextBox? Something like this:
>
> insert into visit_table (date, id) values (@DATE, (select top 1 id
> from id_table where name = NameBox.Text))
>
> What would the InsertCommand for a SQLDataSource look like in VB.NET
> to do this? I have beat my head on it for hours with no luck.
>
> Dave
>