在课堂上插入常用方法 [英] make common method for insert in class
本文介绍了在课堂上插入常用方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好
我想在一个类中插入一个常用的方法,我可以在任何形式上访问任何没有参数的表格使用c#
Plzz帮我这样做
提前致谢
Heera Midha
Hello
I Want to Make a Common Method to Insert In Class That I Can Access on any form with any no of parameters using c#
Plzz Help me to do This
Thanks in Advance
Heera Midha
推荐答案
public bool InsertUpdateDelete(string command)
{
try
{
connection.open ();
sqlCommand cmd = new SqlCommand(命令,连接);
int count = command.ExecuteNonQuerry();
if(count> ; 0)
{
bool result = true;
}
else
{
result = false;
}
}
catch(例外情况)
{
throw;
}
终于
{
连接.close();
}
}
//如果返回true操作成功
else
失败
public bool InsertUpdateDelete(string command)
{
try
{
connection.open();
sqlCommand cmd=new SqlCommand(command,connection);
int count=command.ExecuteNonQuerry();
if(count>0)
{
bool result=true;
}
else
{
result=false;
}
}
catch(Exception ex)
{
throw;
}
finally
{
connection.close();
}
}
//if it returns true operation is successful
else
failed
这篇关于在课堂上插入常用方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文