SqlCommand.Parameters 属性
2012-02-16 21:46
288 查看
SqlCommand.Parameters 属性
这种方法比较灵活,记录于此。
from:http://msdn.microsoft.com/zh-cn/library/system.data.sqlclient.sqlcommand.parameters.aspx
private static void UpdateDemographics(Int32 customerID, string demoXml, string connectionString) { // Update the demographics for a store, which is stored // in an xml column. string commandText = "UPDATE Sales.Store SET Demographics = @demographics " + "WHERE CustomerID = @ID;"; using (SqlConnection connection = new SqlConnection(connectionString)) { SqlCommand command = new SqlCommand(commandText, connection); command.Parameters.Add("@ID", SqlDbType.Int); command.Parameters["@ID"].Value = customerID; // Use AddWithValue to assign Demographics. // SQL Server will implicitly convert strings into XML. command.Parameters.AddWithValue("@demographics", demoXml); try { connection.Open(); Int32 rowsAffected = command.ExecuteNonQuery(); Console.WriteLine("RowsAffected: {0}", rowsAffected); } catch (Exception ex) { Console.WriteLine(ex.Message); } } }
这种方法比较灵活,记录于此。
from:http://msdn.microsoft.com/zh-cn/library/system.data.sqlclient.sqlcommand.parameters.aspx
相关文章推荐
- SqlCommand.Connection 属性
- SqlCommand.DeriveParameters failed
- SqlCommand.Parameters.Add()用法
- SqlCommand.Parameters.add()
- SqlCommand.DeriveParameters failed
- 一份礼物: 自动填充SqlCommand.Parameters的类(2)
- 一份礼物: 自动填充SqlCommand.Parameters的类(1)
- SqlDataSource_Inserted SqlDataSource2.SelectParameters[0].DefaultValue = e.Command.Parameters[2].Value.ToString();
- SqlDataSource.SelectParameters 属性(摘)
- SqlDataAdapter.UpdateCommand 属性(极易出错的地方)(转自:http://blog.csdn.net/tsapi/archive/2011/03/29/6286654.aspx)
- SqlCommand.DeriveParameters failed
- SqlCommand.Parameters其实是用的存储过程sp_executesql
- SqlCommand.Parameters的使用
- 我想操作的是利用SqlDataAdapter的几个Command属性(InsertCommand,UpdateCommand,DeleteCommand)来更新数据库
- SqlDataAdapter.UpdateCommand 属性(极易出错的地方)
- SqlCommandBuilder.DeriveParameters设置储存过程参数
- SqlDataAdapter SelectCommand,InsertCommand,UpdateCommand,DeleteCommand 属性
- SqlConnection.ConnectionTimeout 与 SqlCommand.CommandTimeout 及SqlBulkCopy.BulkCopyTimeout属性
- SqlCommand.Parameters.add()方法
- 小技巧(6)获取表结构属性和描述的SQL语句