Monday, April 30, 2012

Data Saving with stored procedure in VB.NET


Dim cmm = New SqlCommand
            cmm.CommandType = CommandType.StoredProcedure
            cmm.CommandText = "sp_facility_addupdate"
            cmm.Parameters.Add("@facility_id", SqlDbType.BigInt, 0).Value = Convert.ToInt64(hdnFac_ID.Value)
            cmm.Parameters("@facility_id").Direction = ParameterDirection.InputOutput

            cmm.Parameters.Add("@location_id", SqlDbType.BigInt, 0).Value = Convert.ToInt64(Session("Location_ID"))

            cmm.Parameters.Add("@facility_name", SqlDbType.VarChar, 50).Value = txtFacNm.Text
            If ddl_FacilityType.SelectedValue = 1 Then
                cmm.Parameters.Add("@facility_type", SqlDbType.VarChar, 50).Value = "Production Facility"
            ElseIf ddl_FacilityType.SelectedValue = 2 Then
                cmm.Parameters.Add("@facility_type", SqlDbType.VarChar, 50).Value = "Repair Facility"
            ElseIf ddl_FacilityType.SelectedValue = 3 Then
                cmm.Parameters.Add("@facility_type", SqlDbType.VarChar, 50).Value = "Warehouse"
            ElseIf ddl_FacilityType.SelectedValue = 4 Then
                cmm.Parameters.Add("@facility_type", SqlDbType.VarChar, 50).Value = "Consolidation Center"
            End If
            cmm.Parameters.Add("@address_1", SqlDbType.VarChar, 50).Value = txtAddr1.Text
            cmm.Parameters.Add("@address_2", SqlDbType.VarChar, 50).Value = txtAddr2.Text
            cmm.Parameters.Add("@city", SqlDbType.VarChar, 50).Value = txtCity.Text
            cmm.Parameters.Add("@state", SqlDbType.VarChar, 50).Value = txtState.Text
            cmm.Parameters.Add("@country", SqlDbType.VarChar, 50).Value = ddl_country.SelectedValue
            cmm.Parameters.Add("@zip", SqlDbType.VarChar, 50).Value = txtZip.Text
            cmm.Parameters.Add("@phone", SqlDbType.VarChar, 50).Value = txtPhone.Text
            cmm.Parameters.Add("@isdcode", SqlDbType.VarChar, 20).Value = txtisdcode.Text
            cmm.Parameters.Add("@created_id", SqlDbType.BigInt, 0).Value = Convert.ToInt64(lblCreator_ID_Fac.Text)
            cmm.Parameters.Add("@last_update_id", SqlDbType.BigInt, 0).Value = Convert.ToInt64(dt.Rows(0)("user_id").ToString())

            DataConnect.GetInstance.ExecuteNonQuery(cmm)

No comments:

Using Authorization with Swagger in ASP.NET Core

 Create Solution like below LoginModel.cs using System.ComponentModel.DataAnnotations; namespace UsingAuthorizationWithSwagger.Models {     ...