store_proc
[List][Prev][Next]
call store proc from aspx.vb [ Preview ]

Public Class dataRthem
Inherits System.Web.UI.Page
Protected WithEvents DataGrid1 As System.Web.UI.WebControls.DataGrid

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
Protected WithEvents lstCustomers As System.Web.UI.WebControls.ListBox

#End Region
Dim sqlConString As String = _
"server=(local);database=northwind;integrated security=SSPI"

Function LoadOrders(ByVal CID As String) As Boolean
Dim sqlC As New SqlClient.SqlConnection(sqlConString)
'Dim SQL As String = " SELECT * from orderId WHERE CustomerID='" & CID & "'"
'Dim SQL As String = " SELECT customerID,employeeID,orderDate,requiredDate from orderId WHERE CustomerID='" & CID & "'"
'Dim cmdCustomer As New SqlClient.SqlCommand("select customerID,companyName from dbo.customers", sqlC)
Dim cmdCustomer As New SqlClient.SqlCommand("dbo.GetOrdersByCustomerID", sqlC)
cmdCustomer.CommandType = CommandType.StoredProcedure
Dim prm As SqlClient.SqlParameter
prm = New SqlClient.SqlParameter("@Customer", SqlDbType.NChar, 5, ParameterDirection.Input)
prm.Value = CID
cmdCustomer.Parameters.Add(prm)

Dim datRdr As SqlClient.SqlDataReader
Try
sqlC.Open()
datRdr = cmdCustomer.ExecuteReader
DataGrid1.DataSource = datRdr
DataGrid1.DataBind()
datRdr.Close()
Return True
Catch exCust As Exception
Return False
Finally
sqlC.Close()

End Try


End Function

Function LoadCustomerList() As Boolean
Dim iRowcount As Int32
Dim sqlC As New SqlClient.SqlConnection(sqlConString)

'Dim cmdCustomer As New SqlClient.SqlCommand("select customerID,companyName from dbo.customers", sqlC)
Dim cmdCustomer As New SqlClient.SqlCommand("customerList", sqlC)
cmdCustomer.CommandType = CommandType.StoredProcedure

Dim datRdr As SqlClient.SqlDataReader
Try
sqlC.Open()
datRdr = cmdCustomer.ExecuteReader
lstCustomers.DataSource = datRdr
lstCustomers.DataTextField = "CompanyName"
lstCustomers.DataValueField = "customerID"
lstCustomers.DataBind()
datRdr.Close()
Return True
Catch exCust As Exception
Return False
Finally
sqlC.Close()

End Try


End Function

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not Me.IsPostBack Then
LoadCustomerList()

End If
End Sub

Private Sub lstCustomers_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstCustomers.SelectedIndexChanged

LoadOrders(lstCustomers.SelectedItem.Value)

End Sub
End Class

<%//# DataBinder.Eval(Container.DataItem, "album_title") %>
<%//# DataBinder.Eval(Container.DataItem, "contenttype") + " views" %>
link list for hairwigbeautyshop.com ::
Javascript Source List :