Progress Monitor for IdealProgrammer.com
Take Swift, Intelligent, Massive, Planned, Loving, Effective (S.I.M.P.L.E.) Action to Transform Self into Ideal
Skip Repetitive Navigational Links
Home
News
Presenters
Register
Contact
Categories
Titles
Converter
Code Samples
C# ASP.NET
C# Console
HTML
JavaScript
SQL Server
VB ASP.NET
VB Console
Please login
VB.NET
Description:
Illustrates using Sql Stored Procedure with SqlDataReader.
Example Class:
Imports System Imports System.Data Imports System.Data.SqlClient Public Class clsSQLCallStoredProcedure Shared WithEvents con As SqlConnection Sub Main() con = New SqlConnection("Server=(local)\SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=SSPI") Dim cmd As New SqlCommand("Sales By Year", con) cmd.CommandType = CommandType.StoredProcedure ' Add Parameters to Command Parameters collection cmd.Parameters.Add("@Beginning_Date", SqlDbType.DateTime) cmd.Parameters.Add("@Ending_Date", SqlDbType.DateTime) cmd.Parameters("@Beginning_Date").Value = "1/1/1990" cmd.Parameters("@Ending_Date").Value = "1/1/2000" Try con.Open() Dim reader As SqlDataReader = cmd.ExecuteReader() While reader.Read() Console.WriteLine("{0} - {1:c}", _ reader.GetDateTime(0), reader.GetDecimal(2)) End While reader.Close() Finally con.Close() End Try Console.ReadLine() End Sub End Class
Example Module:
Module Module1 Sub Main() '***** DataBaseADONET ************* Dim mySQLCallStoredProcedure As New clsSQLCallStoredProcedure mySQLCallStoredProcedure.Main() End Sub End Module
Home
News
Presenters
Register
Contact
Categories
Titles
Converter
Code Samples
C# ASP.NET
C# Console
HTML
JavaScript
SQL Server
VB ASP.NET
VB Console