oleDbCommand1 = new OleDbCommand("myprocedure",oleDbConnection1);
oleDbCommand1.CommandType = CommandType.StoredProcedure;
//oleDbCommand1.Parameters.Add("CommandType",1); oleDbCommand1.Parameters.Add("commandtype",OleDbType.Integer);
p_errorid = oleDbCommand1.Parameters.Add("ErrorID",OleDbType.Integer);
p_errormsg = oleDbCommand1.Parameters.Add("ErrorMsg",OleDbType.VarChar,30);
p_errorid.Direction = ParameterDirection.Output;
p_errormsg.Direction = ParameterDirection.Output; oleDbConnection1.Open();
oleDbCommand1.ExecuteNonQuery();
Label1.Text = oleDbCommand1.Parameters["ErrorMsg"].Value.ToString();
oleDbConnection1.Close();
oleDbCommand1.CommandType = CommandType.StoredProcedure;
//oleDbCommand1.Parameters.Add("CommandType",1); oleDbCommand1.Parameters.Add("commandtype",OleDbType.Integer);
p_errorid = oleDbCommand1.Parameters.Add("ErrorID",OleDbType.Integer);
p_errormsg = oleDbCommand1.Parameters.Add("ErrorMsg",OleDbType.VarChar,30);
p_errorid.Direction = ParameterDirection.Output;
p_errormsg.Direction = ParameterDirection.Output; oleDbConnection1.Open();
oleDbCommand1.ExecuteNonQuery();
Label1.Text = oleDbCommand1.Parameters["ErrorMsg"].Value.ToString();
oleDbConnection1.Close();
解决方案 »
- jQuery mobel 1.2 mise无效
- System.FormatException - GUID 应包含带 4 个短划线的 32 位数()
- 服务器域名解析问题~~~~~~~~~旧数据地址被改变了
- 求救,怎样捕捉连接错误
- 菜鸟求助:绑定列时如何输出正确的html
- 关于“无法获取执行权限"的问题
- Session为何不能保值
- 用户访问我的xml要提供用户名和密码,该怎么做?
- 关于dataset
- 奇怪问题,网站要做一计数器,Global.asax中的Session_Start好象过程不执行。2003 OS,是不是操作系统的总题?
- 请教:如何将asp.net中的.aspx文件在dreamweaver mx中修改,然后再在.net中使用?
- 简单的问题但你们不一定会,请看,会有受益的!
Dim nwindConn As SqlConnection = New SqlConnection("Data Source=localhost;Integrated Security=SSPI;" & _
"Initial Catalog=northwind")Dim salesCMD As SqlCommand = New SqlCommand("SalesByCategory", nwindConn)
salesCMD.CommandType = CommandType.StoredProcedureDim myParm As SqlParameter = salesCMD.Parameters.Add("@CategoryName", SqlDbType.NVarChar, 15)
myParm.Value = "Beverages"nwindConn.Open()Dim myReader As SqlDataReader = salesCMD.ExecuteReader()Console.WriteLine("{0}, {1}", myReader.GetName(0), myReader.GetName(1))Do While myReader.Read()
Console.WriteLine("{0}, ${1}", myReader.GetString(0), myReader.GetDecimal(1))
LoopmyReader.Close()
nwindConn.Close()
[C#]
SqlConnection nwindConn = new SqlConnection("Data Source=localhost;Integrated Security=SSPI;Initial Catalog=northwind");SqlCommand salesCMD = new SqlCommand("SalesByCategory", nwindConn);
salesCMD.CommandType = CommandType.StoredProcedure;SqlParameter myParm = salesCMD.Parameters.Add("@CategoryName", SqlDbType.NVarChar, 15);
myParm.Value = "Beverages";nwindConn.Open();SqlDataReader myReader = salesCMD.ExecuteReader();Console.WriteLine("{0}, {1}", myReader.GetName(0), myReader.GetName(1));while (myReader.Read())
{
Console.WriteLine("{0}, ${1}", myReader.GetString(0), myReader.GetDecimal(1));
}myReader.Close();
nwindConn.Close();