SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 22 | Next

Scott Klein

"Professional LINQ"

CreateCommand();
Part I: Introduction to Project LINQ
cmd.CommandType = CommandType.Text;
cmd.CommandText = "SELECT LastName, FirstName FROM
Person.Contact";
using (SqlDataReader rdr = cmd.ExecuteReader())
{
/ / do something
}
}
}
If you wanted to use the same code to execute a stored procedure that takes one or more parameters, it
might look like this:
private void Form1_Load(object sender, EventArgs e)
{
string ConnectionString = @"Data Source=(local);
Initial Catalog=AdventureWorks;UID=sa;PWD=yourpassword";
using (SqlConnection conn = new SqlConnection(ConnectionString))
{
conn.Open();
SqlCommand cmd = conn.CreateCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "uspGetBillOfMaterials";
cmd.Parameters.Add("@StartProductID", SqlDbType.Int).Value =
324;
cmd.Parameters.Add("@CheckDate", SqlDbType.DateTime).Value =
"07/10/2000";
using (SqlDataReader rdr = cmd.ExecuteReader())
{
// do something
}
}
}
While you and I have probably coded something like this many, many times, it isn??™t ??????friendly??™??™ on several
levels.


Pages:
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6