Top "Sqlcommand" questions

Represents a Transact-SQL statement or stored procedure to execute against a SQL Server database which is used in Microsoft .NET.

How do I translate a List<string> into a SqlParameter for a Sql In statement?

I seem to be confused on how to perform an In statement with a SqlParameter. So far I have the …

c# sql ado.net sqlcommand
How can I get an error message that happens when using ExecuteNonQuery()?

I am executing a command in this way : var Command = new SqlCommand(cmdText, Connection, tr); Command.ExecuteNonQuery(); In the command …

c# sql ado.net sqlcommand
Do I have to Close() a SQLConnection before it gets disposed?

Per my other question here about Disposable objects, should we call Close() before the end of a using block? using (…

c# asp.net using sqlconnection sqlcommand
Passing a parameter to an sql stored procedure in c#

string commandGetIslemIdleri = ("EXEC GetIslemIdleri"); cmd = new SqlCommand(commandGetIslemIdleri, sqlConn); cmd.Parameters.Add(new SqlParameter("@CARIID", 110)); using (var reader = cmd.ExecuteReader()) //…

c# stored-procedures parameter-passing sqlcommand
Parameter.addwithvalue - ExecuteReader: CommandText property has not been initialized

I get the error ExecuteReader: CommandText property has not been initialized at the adapter.fill(ds) line. The weird thing …

c# asp.net sqlcommand
SqlCommand (Using Statement / Disposing issue)

Take the following example... Using cn As New SqlConnection(ConnectionString) Try Dim cmd As SqlCommand = New SqlCommand With cmd .Connection = …

vb.net dispose sqlcommand using-statement
C# Update Table using SqlCommand.Parameters

I'm trying to update an MSSQL table using SqlCommand, I think it's a syntax error with my T-SQL, but here …

c# sql sqlcommand sqlclient
SqlCommand with using statement

I saw that in most samples SqlCommand was used like this using (SqlConnection con = new SqlConnection(CNN_STRING)) { using (SqlCommand …

c# sqlconnection sqlcommand using-statement
Under what circumstances is an SqlConnection automatically enlisted in an ambient TransactionScope Transaction?

What does it mean for an SqlConnection to be "enlisted" in a transaction? Does it simply mean that commands I …

c# ado.net transactionscope sqlconnection sqlcommand
Is SqlCommand.Dispose() required if associated SqlConnection will be disposed?

I usually use code like this: using (var connection = new SqlConnection(ConfigurationManager.ConnectionStrings["MyConn"].ConnectionString)) { var command = connection.CreateCommand(); command.…

c# ado.net dispose sqlconnection sqlcommand