如何使用存储过程将数据从前端插入到数据库 [英] How to insert data from front end to database using store procedure

查看:638
本文介绍了如何使用存储过程将数据从前端插入到数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很擅长使用商店程序。我想使用类在MSSQL2008R2中使用存储过程插入数据。我在类文件中写代码为belove

  public   static   void  insertdata( string  storeprocName, int  no, string  name)
{
sqlcommend cmd = new sqlcommend (storeprocName,connection);
cmd.commandtype = system。 data.commandtype.storeprocedure;
cmd.parameters。 add @ no,sqldbtype。 int value = no;
cmd.parameters。 add @ name,sqldbtype.text) value = name;
con.open();
cmd.executenonquery();
con.close();
}



现在如何从插入按钮上的前端捕获值点击

我不确定上面的代码请建议我解决方案。

解决方案

请参阅 https://www.google .com / search?q = storedprocedure%20mssql [ ^ ]。

I am biggener to use store procedure. I want to insert data using store procedure in MSSQL2008R2 using class. I write code in class file as belove

public static void insertdata(string storeprocName, int no, string name)
{
    sqlcommend cmd= new sqlcommend(storeprocName, connection);
    cmd.commandtype= system. data.commandtype.storeprocedure;
    cmd.parameters.add("@no", sqldbtype.int)value= no;
    cmd.parameters.add("@name", sqldbtype.text)value= name;
    con.open();
    cmd.executenonquery();
    con.close();
}


now how to catch values from frontend on insert button click
I am not sure for above code please suggest me solution.

解决方案

See https://www.google.com/search?q=storedprocedure%20mssql[^].


这篇关于如何使用存储过程将数据从前端插入到数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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