• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 969
  • Last Modified:

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'
)
0
countrymeister
Asked:
countrymeister
  • 2
  • 2
1 Solution
 
p_davisCommented:
you could use the sqldataadapters executenonquery method.
0
 
prosh0tCommented:
0
 
p_davisCommented:
           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
0
 
countrymeisterAuthor Commented:
I am looking more for the syntax of setting the SQL command, and also the connection object
0
 
countrymeisterAuthor Commented:
prosh0t,

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

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now