http://www.yesky.com/20021112/1639498.shtml
这有个例子,在Visual Basic .NET中使用存储过程。

解决方案 »

  1.   

    thisConnection = new SqlConnection(
    @"server = CELERON\SQL2000;"+
    "integrated Security = sspi;"+
    "Database = Northwind");

    thisConnection.Open();

    cmd  = thisConnection.CreateCommand();
    cmd.CommandType = CommandType.StoredProcedure;
    cmd.CommandText = "sp_Select_AllEmployees";
    dr = cmd.ExecuteReader();
    zxzt.Text = "成功查询无参数存储过程 sp_Select_AllEmployees ";
      

  2.   

    看看这个是否有用
    OleDbCommand comm = new OleDbCommand("",Class.PubObject.DBConnObj);
    comm.CommandType = CommandType.StoredProcedure;
    comm.CommandText = "InvoiceInfo";
    comm.Parameters.Add("@financeMonth",OleDbType.WChar).Value = this.comboBoxYear.Text+this.comboBoxMonth.Text;
    comm.Parameters.Add("@accountID",OleDbType.WChar).Value = aimTree.SelectedNode.Tag.ToString();  
    comm.ExecuteNonQuery();
      

  3.   

    //执行存储过程,PUB_SYS_LOG为存储过程名
    public static bool InsertGMonitorLog(int sysPrgId,string logType,ing logOperationMsg)
    {
    bool blnRst = false;
    SqlConnection myConn = new SqlConnection(strConn);
    SqlCommand myComm = new SqlCommand("PUB_SYS_LOG",myConn);
    myComm.CommandType = CommandType.StoredProcedure; SqlParameter myPara = new SqlParameter("@SYS_PRG_ID",SqlDbType.Int);
    myPara.Value = sysPrgId;
    myComm.Parameters.Add(myPara); myPara = new SqlParameter("@LOG_TYPE",SqlDbType.VarChar,3);
    myPara.Value = logType;
    myComm.Parameters.Add(myPara); myPara = new SqlParameter("@LOG_OPERATION_MSG",SqlDbType.VarChar,50);
    myPara.Value = logOperationMsg;
    myComm.Parameters.Add(myPara);

    try
    {
    myConn.Open();
    myComm.ExecuteNonQuery();
    blnRst = true;
    }
    catch(SqlException e)
    {
    e.ToString();
    }
    finally
    {
    myConn.Close();
    }
    return blnRst;
    }