We help IT Professionals succeed at work.

How to excute an inline SQL from .NET

I have a SQL statement that I need to excute from my C# code, I know I have to set the select command to the text , but I also need to set the use statement indicating which database to use.

The language is C# and the database is SQL Server 2005

Here is my SQL

use dbArea
go
delete LogDetail
where ID in (
select ID from LogSummary
where Date = '1/18/2008'
and Area = 'EAST'
)
Comment
Watch Question

BRONZE EXPERT

Commented:
you could use the sqldataadapters executenonquery method.
BRONZE EXPERT

Commented:
           System.Data.SqlClient.SqlDataAdapter sda =
                new System.Data.SqlClient.SqlDataAdapter();
            sda.DeleteCommand.ExecuteNonQuery();


sorry if that was confusing but it can still be reached through the data adapter

Author

Commented:
I am looking more for the syntax of setting the SQL command, and also the connection object

Author

Commented:
prosh0t,

Sorry about that, I do see the link has an example

Explore More ContentExplore courses, solutions, and other research materials related to this topic.