如何从C Sharp更新SQL Server表 [英] how to update sql server table from c sharp

查看:131
本文介绍了如何从C Sharp更新SQL Server表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个存储过程名称"proc_function"

有三个参数

i have one stored procedure name "proc_function"

with three arguments

@u_id
@u_name
@u_ip



现在从c Sharp,我必须用"proc_function"
更新我的表
这是我写的代码,但我不知道该怎么做

更新我的表



and now from c sharp i have to update my table by "proc_function"

here is the code which i wrote it but i don''t know what to do next to

update my table

sql_string = ("Data Source=23423423423;Initial Catalog=sdfgsdf;User Id=dsfsdsa;Password=sdfsdf;");
 SqlConnection conn = new SqlConnection(sql_string);
 SqlCommand command = new SqlCommand("proc_function", conn);
 conn.Open();
 command.CommandType = CommandType.StoredProcedure;
 command.Parameters.AddWithValue("@usd", u_id);
 command.Parameters.AddWithValue("@uname", u_name );
 command.Parameters.AddWithValue("@uip", local_ip);



下一步做什么......



what to do next ...............

推荐答案

将此代码写在您的代码下方.然后它应该可以工作.

Write this below your code. It should then work.

command.ExecuteNonQuery();
command.Dispose();
conn.Close();


这篇关于如何从C Sharp更新SQL Server表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆