Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Executing Stored Procs With Params
Message
Information générale
Forum:
ASP.NET
Catégorie:
Bases de données
Divers
Thread ID:
00979533
Message ID:
00979717
Vues:
18
Ok, I have a test function. I'm getting a dataset with
no records. There is one record in Customers with an
Id of type nchar, and a value of 'SMITH'.

Here's ny code:
Public Sub StoredProcExample()

        ' Create a new Connection
        Dim oConnection As SqlConnection
        oConnection = New SqlConnection("data source=(local);initial catalog=BM; user id=kevin; password=mypw")
        oConnection.Open()

        Dim oDataSet As New DataSet

        Dim oSqlAdapter = New SqlDataAdapter("sp_GetCustomerById", oConnection)

        oSqlAdapter.SelectCommand.CommandType = CommandType.StoredProcedure
        oSqlAdapter.SelectCommand.Parameters.Add("@CustomerId", "SMITH")

        oSqlAdapter.Fill(oDataSet, "Customers")

        Dim oDataRow As DataRow

        For Each oDataRow In oDataSet.Tables("Customers").Rows
            Console.WriteLine(oDataRow("CustomerId").ToString())
        Next

        oConnection.Close()

    End Sub
>Kevin,
>
>Here's a very simple stored proc to return the entire customer record for a customer PK...
>
>
>CREATE PROCEDURE GetCustomerByPK (@nCustomerPK int)
> AS
>
>	SELECT * FROM Customer WHERE CustomerPK = @nCustomerPK
>GO
>
>
>You may want to check BOL (books online) for more details on creating SPs.
>
>Kevin
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform