我在C#后台中获取了数据库表中我需要的字段的值(是以string的类型取出来的),然后我已经将这些值进行了操作,得到了新的数据(string类型)将得到的新数据 存储string数据库 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 数据库基础 insert和update 不就是普通的插入更新操作吗,msdn上都有示例代码 参考实例:http://blog.163.com/qqabc20082006@126/blog/static/229285252009719104647132/ int id = 0; //使用存储过程实现添加数据 //proc_AddUser为存储过程名称 using (SqlCommand command = new SqlCommand("proc_AddUser", DBService.Conn)) { //指定command对象的执行方式 command.CommandType = CommandType.StoredProcedure; //指定存储过程的参数并赋值 command.Parameters.Add("@uName",SqlDbType.NVarChar,20).Value = user.Name; command.Parameters.Add("@uAge", SqlDbType.Int).Value = user.Age; command.Parameters.Add("@uPass", SqlDbType.NVarChar, 200).Value = user.Password; //设置输出参数 command.Parameters.Add("@uId", SqlDbType.Int).Direction =ParameterDirection.Output; //@uId,@uName等参数必须与数据库存储过程中的参数一致 //执行 command.ExecuteNonQuery(); //获取输出参数的值 id = Convert.ToInt32(command.Parameters["@uId"].Value);f exists (select * from sysobjects where name = 'proc_AddUser')drop proc proc_AddUsergocreate procedure proc_AddUser@uId int output,@uName nvarchar(20),@uAge int,@uPass nvarchar(200)with encryption --对存储过程进行加密asinsert into UserInfo (uName,uAge,password) values (@uName,@uAge,@uPass)select @uId = @@identitygo 非绑定数据源的DataGridView怎么实现筛选功能? 高手进来帮忙解决下,谢谢了先 VS2010下“工具箱中的控件”不见了,Why??? ID“Form1”已被其他控件使用,什么问题??急问! 如何根据字符串内含有的逗号拆分一字符串, 菜鸟问题!如何再次将窗体显示出来? 有什么办法能使我,不用Timer控件得情况下,可以在1小时激发一次事件? 求个真正表达式,高手出手吧 c#中静态变量的问题 Gif 解析的frame 赋给Image的source ,资源怎么释放不了,求解决 Webbrowser 登录成功后有时会莫名其妙回退到登录页 关于vs2008和vs2013的问题
数据库基础 insert和update
int id = 0;
//使用存储过程实现添加数据
//proc_AddUser为存储过程名称
using (SqlCommand command = new SqlCommand("proc_AddUser", DBService.Conn))
{
//指定command对象的执行方式
command.CommandType = CommandType.StoredProcedure;
//指定存储过程的参数并赋值
command.Parameters.Add("@uName",SqlDbType.NVarChar,20).Value = user.Name;
command.Parameters.Add("@uAge", SqlDbType.Int).Value = user.Age;
command.Parameters.Add("@uPass", SqlDbType.NVarChar, 200).Value = user.Password;
//设置输出参数
command.Parameters.Add("@uId", SqlDbType.Int).Direction =ParameterDirection.Output; //@uId,@uName等参数必须与数据库存储过程中的参数一致
//执行
command.ExecuteNonQuery();
//获取输出参数的值
id = Convert.ToInt32(command.Parameters["@uId"].Value);f exists (select * from sysobjects where name = 'proc_AddUser')
drop proc proc_AddUser
go
create procedure proc_AddUser
@uId int output,
@uName nvarchar(20),
@uAge int,
@uPass nvarchar(200)
with encryption --对存储过程进行加密
as
insert into UserInfo (uName,uAge,password) values (@uName,@uAge,@uPass)
select @uId = @@identity
go