编程语言

img bgu

[ASP.net(C#)]最简单的一个存储过程

发表于2004/10/18 16:06:00  1285人阅读

SQL server存储:
======================================

CREATE PROCEDURE AddNew
@content text
 AS insert into test values (@content)
GO

======================================

CS调用代码:
======================================

string sqlString = "AddNew";
   SqlConnection conn = new SqlConnection(ConfigurationSettings.AppSettings["sqlConnection"]);
   SqlCommand cmd = new SqlCommand(sqlString,conn);
   cmd.CommandType = CommandType.StoredProcedure;
   SqlParameter param = new SqlParameter();
   param = cmd.Parameters.Add("@content",SqlDbType.Text);
   param.Direction = ParameterDirection.Input;
   param.Value= "zzzzzzzzzzzzzzz";
   conn.Open();
   cmd.ExecuteNonQuery();
   cmd.Dispose();
   conn.Close();
   conn.Dispose();

===================================
阅读全文
0 0

相关文章推荐

img
取 消
img