也是关于存储过程的

Hilltown Hilltown 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我在sql中创建了一个存储过程:
CREATE PROCEDURE n_addTopic @a_strTitle char(40),@a_strAuthor char(40),@a_strContent char(40)AS
insert into guestbook (Author,Title,Content) values(@a_strTitle,@a_strAuthor,@a_strContent)
GO
程序代码:
SqlConnection conn=new SqlConnection(sql);
SqlCommand myCommand=new SqlCommand("n_addTopic",conn);
myCommand.CommandType = CommandType.StoredProcedure ;


myCommand.Parameters.Add(new SqlParameter("@a_strTitle" , SqlDbType.VarChar,100)) ;
myCommand.Parameters["@a_strTitle"].Value = n_Topic.Title ;

myCommand.Parameters.Add(new SqlParameter("@a_strAuthor" , SqlDbType.VarChar,50)) ;
myCommand.Parameters["@a_strAuthor"].Value = n_Topic.Author ;

myCommand.Parameters.Add(new SqlParameter("@a_strContent" , SqlDbType.VarChar,2000)) ;
myCommand.Parameters["@a_strContent"].Value = n_Topic.Content ;

myCommand.ExecuteNonQuery()
执行后,怎么数据库有两条相同的记录?
...全文
评论 2
收藏 已收藏
分享
返回顶部
Hilltown
.NET社区 62,272 成员 668,968 内容