VB.NET and SQLDataSource

D

Dave

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
 
G

Guest

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


insert into visit_table (date, id)
select top 1 @DATE, id
from id_table where name = ...
 
C

Cowboy \(Gregory A. Beamer\)

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!
*********************************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,610
Members
45,255
Latest member
TopCryptoTwitterChannels

Latest Threads

Top