怎样在C#与SQL SERVER2000写的程序调用存储过程 C#与SQL SERVER2000写的程序存储过程的调用方法是怎样的.哪位高手给指点一下 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 DataSet dataSet = new DataSet();SqlDataAdapter adapter = new SqlDataAdapter();adapter.SelectCommand = CreateCommand(procName,null);adapter.SelectCommand.CommandType = CommandType.StoredProcedure;adapter.Fill(dataSet,tableName); string source="server=127.0.0.1;uid=sa;pwd=xxx;database=ddd";SqlConnection sqlconn=new SqlConnection(source);sqlconn.Open();//SqlCommand cmd=new SqlCommand("存储过程的名称",sqlconn);//设置cmd对象的类型是调用存储过程cmd.CommandType=CommandType.StoredProcedure;cmd.Parameters.Add(new SqlParameter("@参数",SqlDbType.NVarChar));cmd.Parameters.Add(new SqlParameter("@返回参数",SqlDbType.Int,0,ParameterDirection.Output,false,0,0,"返回参数",DataRowVersion.Default,null));//给参数赋值cmd.Parameters["@参数"].Value="abc"; //执行命令cmd.ExecuteNonQuery();//取返回参数x=(int)cmd.Parameters["@GDID"].Value; 是否在.net中也是这样调用的啊另外头文件什么的要加吗?怎么加 SqlCommand command = new SqlCommand(); command.CommandText = "DeleteMrContact"; command.CommandType = CommandType.StoredProcedure; command.Connection = con; SqlParameter param = new SqlParameter(paramChg(EmpConData.CONID_FIELD),SqlDbType.Int); param.Value = conID; command.Parameters.Add(param); con.Open(); int result = command.ExecuteNonQuery(); con.Close(); if(result>0) { return true; } else { return false; } using System;using System.Data;using System.Data.SqlClient;using System.Windows.Forms;using System.Collections;public static DataSet ExeStoreProcedureReturnDataSet(string sSpName, ArrayList arParameter) { try { dbCnn.Close(); dbCnn.Open(); SqlDataAdapter spAdapter = new SqlDataAdapter(); SqlCommand spCommand = new SqlCommand(sSpName, dbCnn); spCommand.CommandType = CommandType.StoredProcedure; for (int i = 0; i < arParameter.Count; i++) { spCommand.Parameters.Add(arParameter[i]); } spAdapter.SelectCommand = spCommand; DataSet ds = new DataSet(); spAdapter.Fill(ds, "Return"); return ds; } catch (Exception e) { MessageBox.Show(e.Message, "执行存储过程失败"); return null; } finally { dbCnn.Close(); } } 问个白痴问题................. 各位大侠,这个软件是杂个实现的呢? 关于ADO.NET的DATASET和DATATABLE 求一存储过程 多谢!!!!!!!!!!!!!!! 为什么安装ComponentOne组件后,在工具箱上没有显示呢? Ado.net特性的疑问 如何将combobox的数据源设定为Hashtable 高手帮个忙急 必须声明变量 '@id'。 错误提示 各位大哥,请问哪里有Visual Studio .NET下载,还有,它出正式版了么 求正则表达式 C#连接数据库的方法 c#中 一个string 是否含有另一个string 怎么判断的?
SqlDataAdapter adapter = new SqlDataAdapter();
adapter.SelectCommand = CreateCommand(procName,null);
adapter.SelectCommand.CommandType = CommandType.StoredProcedure;
adapter.Fill(dataSet,tableName);
string source="server=127.0.0.1;uid=sa;pwd=xxx;database=ddd";
SqlConnection sqlconn=new SqlConnection(source);
sqlconn.Open();
//
SqlCommand cmd=new SqlCommand("存储过程的名称",sqlconn);
//设置cmd对象的类型是调用存储过程
cmd.CommandType=CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("@参数",SqlDbType.NVarChar));
cmd.Parameters.Add(new SqlParameter("@返回参数",SqlDbType.Int,0,ParameterDirection.Output,false,0,0,"返回参数",DataRowVersion.Default,null));//给参数赋值
cmd.Parameters["@参数"].Value="abc";
//执行命令
cmd.ExecuteNonQuery();
//取返回参数
x=(int)cmd.Parameters["@GDID"].Value;
另外头文件什么的要加吗?怎么加
command.CommandText = "DeleteMrContact";
command.CommandType = CommandType.StoredProcedure;
command.Connection = con; SqlParameter param = new SqlParameter(paramChg(EmpConData.CONID_FIELD),SqlDbType.Int);
param.Value = conID;
command.Parameters.Add(param); con.Open();
int result = command.ExecuteNonQuery();
con.Close();
if(result>0)
{
return true;
}
else
{
return false;
}
using System.Data;
using System.Data.SqlClient;
using System.Windows.Forms;
using System.Collections;
public static DataSet ExeStoreProcedureReturnDataSet(string sSpName, ArrayList arParameter)
{
try
{
dbCnn.Close();
dbCnn.Open();
SqlDataAdapter spAdapter = new SqlDataAdapter();
SqlCommand spCommand = new SqlCommand(sSpName, dbCnn);
spCommand.CommandType = CommandType.StoredProcedure;
for (int i = 0; i < arParameter.Count; i++)
{
spCommand.Parameters.Add(arParameter[i]);
}
spAdapter.SelectCommand = spCommand;
DataSet ds = new DataSet();
spAdapter.Fill(ds, "Return");
return ds;
}
catch (Exception e)
{
MessageBox.Show(e.Message, "执行存储过程失败");
return null;
}
finally
{
dbCnn.Close();
}
}