We Recommend

Accelerated C# 2008 Accelerated C# 2008
This book is both a rapid tutorial and a permanent reference. You’ll quickly master C# syntax while learning how the CLR simplifies many programming tasks. You’ll also learn best practices that ensure your code will be efficient, reusable, and robust. Why spend months or years discovering the best ways to design and code C# when this book will show you how to do things the right way, right from the start?


Posted By

ixia on 01/18/08


Tagged

ADONet using


Versions (?)


Simple insert SPROC call


Published in: C# 


  1. public void LogRequest(string requestor, string messageBody)
  2. {
  3. using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString))
  4. {
  5. conn.Open();
  6. SqlCommand cmd = new SqlCommand("wp_InsertRequest", conn);
  7. cmd.CommandType = CommandType.StoredProcedure;
  8. cmd.Parameters.Add(new SqlParameter("Requestor", requestor));
  9. cmd.Parameters.Add(new SqlParameter("EmailBody", messageBody));
  10. cmd.ExecuteNonQuery();
  11. }
  12. }

Report this snippet 

You need to login to post a comment.