Executing Stored Procedures (SQL)

Hi there,

I have a SQL 2000 DB and have stored procedures within it.

How in VB.NET do i execute these. This is what i did in VB6

Dim objAdoPats As New ADODB.Recordset
Set objAdoCmd = New ADODB.Command
objAdoCmd.CommandType = adCmdStoredProc
objAdoCmd.CommandText = "USP_Reports_ActivePatients"
Set objAdoPats = objAdoCmd.Execute

I need to do exactly the same sort of thing in VB.NET can i use the same sort of thing??

An example of some code would be useful

Thanks

Hunty :-)

Comments

  • : Hi there,
    :
    : I have a SQL 2000 DB and have stored procedures within it.
    :
    : How in VB.NET do i execute these. This is what i did in VB6
    :
    : Dim objAdoPats As New ADODB.Recordset
    : Set objAdoCmd = New ADODB.Command
    : objAdoCmd.CommandType = adCmdStoredProc
    : objAdoCmd.CommandText = "USP_Reports_ActivePatients"
    : Set objAdoPats = objAdoCmd.Execute
    :
    : I need to do exactly the same sort of thing in VB.NET can i use the same sort of thing??
    :
    : An example of some code would be useful
    :
    : Thanks
    :
    : Hunty :-)
    :
    :
    Imports System.Data
    Imports System.Data.SqlClient
    'Dim DS As DataSet
    Dim conn As SqlConnection
    Dim cmdObj As SqlDataAdapter
    'Modify to your settings:
    conn = New SqlConnection("server=localhost;uid=sa;pwd=;database=Pubs")
    'set to the stored procedure
    cmdObj = New SqlDataAdapter("USP_Reports_ActivePatients", conn)
    cmdObj.SelectCommand.CommandType = CommandType.StoredProcedure
    '======================================================================
    'Example adding stored procedure parameters
    'cmdObj.SelectCommand.Parameters.Add(New SqlParameter("@PatientID",
    'SqlDbType.NVarChar, 4))
    'Specifying the parameter value
    'cmdObj.SelectCommand.Parameters("@PatientID").Value = Patient_ID.Text
    'Use the below for the equiv of a recordset:
    'DS = New DataSet()
    'cmdObj.Fill(DS, "Patient")
    '======================================================================
    cmdObj.ExecuteNonQuery()




  • : : Hi there,
    : :
    : : I have a SQL 2000 DB and have stored procedures within it.
    : :
    : : How in VB.NET do i execute these. This is what i did in VB6
    : :
    : : Dim objAdoPats As New ADODB.Recordset
    : : Set objAdoCmd = New ADODB.Command
    : : objAdoCmd.CommandType = adCmdStoredProc
    : : objAdoCmd.CommandText = "USP_Reports_ActivePatients"
    : : Set objAdoPats = objAdoCmd.Execute
    : :
    : : I need to do exactly the same sort of thing in VB.NET can i use the same sort of thing??
    : :
    : : An example of some code would be useful
    : :
    : : Thanks
    : :
    : : Hunty :-)
    : :
    : :
    : Imports System.Data
    : Imports System.Data.SqlClient
    : 'Dim DS As DataSet
    : Dim conn As SqlConnection
    : Dim cmdObj As SqlDataAdapter
    : 'Modify to your settings:
    : conn = New SqlConnection("server=localhost;uid=sa;pwd=;database=Pubs")
    : 'set to the stored procedure
    : cmdObj = New SqlDataAdapter("USP_Reports_ActivePatients", conn)
    : cmdObj.SelectCommand.CommandType = CommandType.StoredProcedure
    : '======================================================================
    : 'Example adding stored procedure parameters
    : 'cmdObj.SelectCommand.Parameters.Add(New SqlParameter("@PatientID",
    : 'SqlDbType.NVarChar, 4))
    : 'Specifying the parameter value
    : 'cmdObj.SelectCommand.Parameters("@PatientID").Value = Patient_ID.Text
    : 'Use the below for the equiv of a recordset:
    : 'DS = New DataSet()
    : 'cmdObj.Fill(DS, "Patient")
    : '======================================================================
    : cmdObj.ExecuteNonQuery()
    :
    :
    : Thanks very much for the reply, it was very useful
    Dave Hunt (Hunty)
    :
    :

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories