Torna al Thread

Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim CN As New SqlConnection("Data Source=.;Initial Catalog=Northwind;Integrated Security=True") Dim customerID As String = InputBox("Please enter a customer ID", "CustomerTotals Stored Procedure", "ALFKI") If customerID.Trim.Length = 0 Then Exit Sub Dim CMD As New SqlCommand CMD.Connection = CN CMD.CommandText = "dbo.CustomerTotals" CMD.CommandType = CommandType.StoredProcedure CMD.Parameters.Add( "@customerID", SqlDbType.VarChar, 5).Value = customerID CMD.Parameters.Add("@customerTotal", SqlDbType.Money) CMD.Parameters("@customerTotal").Direction = ParameterDirection.Output CMD.Parameters.Add("@customerItems", SqlDbType.Int) CMD.Parameters("@customerItems").Direction = ParameterDirection.Output CMD.Parameters.Add("@orders", SqlDbType.Int) CMD.Parameters("@orders").Direction = ParameterDirection.ReturnValue CN.Open() CMD.ExecuteNonQuery() '' CN.Close() Dim items As Integer items = Convert.ToInt32(CMD.Parameters("@customerItems").Value) Dim orders As Integer orders = Convert.ToInt32(CMD.Parameters("@orders").Value) Dim ordersTotal As Decimal ordersTotal = Convert.ToDouble( CMD.Parameters("@customerTotal").Value) TextBox1.Text = "Customer BLAUS has placed " & orders.ToString & " orders " & "totaling $" & Math.Round(ordersTotal, 2).ToString("#,###.00") & " and " & items.ToString & " items" End Sub
Copyright © dotNetHell.it 2002-2025
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5