I have Table Called "ItemsPricesTbl"
Contain :
ItemID
FirstUnitWholeSalePrice
FirstUnitShopperPrice
FirstUnitDemotionsPrice
FirstUnitPriceDefult
SecondUnitWholeSalePrice
SecondUnitShopperPrice
SecondUnitDemotionsPrice
SecondUnitPriceDefult
ThirdUnitWholeSalePrice
ThirdUnitShopperPrice
ThirdUnitDemotionsPrice
ThirdUnitPriceDefult
DefultPrice
The Stored Porc is :
Code:ALTER PROCEDURE [dbo].[Get_Prices_Item_By_ID] @ItemID int as begin Select ItemID,FirstUnitWholeSalePrice,FirstUnitShopperPrice,FirstUnitDemotionsPrice,FirstUnitPriceDefult,SecondUnitWholeSalePrice,SecondUnitShopperPrice,SecondUnitDemotionsPrice,SecondUnitPriceDefult,ThirdUnitWholeSalePrice,ThirdUnitShopperPrice,ThirdUnitDemotionsPrice,ThirdUnitPriceDefult,DefultPrice from ItemsPricesTbl Where ItemID=@ItemID End
in Vb i have DatabaseManager Class Which Have this Code :
Code:Private Function exeReader(ByRef cmd As SqlCommand, ByRef dr As SqlDataReader) As Integer Dim retval As Integer = -1 cmd.Connection = Me.Connection Try If cmd.CommandType = CommandType.StoredProcedure Then Dim pr As New SqlParameter("@retval", SqlDbType.Int) pr.Direction = ParameterDirection.ReturnValue cmd.Parameters.Add(pr) End If If cmd.Connection.State = ConnectionState.Closed Then cmd.Connection.Open() dr = cmd.ExecuteReader() If cmd.CommandType = CommandType.StoredProcedure Then retval = cmd.Parameters("@retval").Value Catch ex As Exception Throw New Exception(ex.Message) Finally Me.close() End Try Return retval End Function
Also I have two classes The Data Class And Business Class .
Data Class Code :
And Business Class Code :Code:Friend Function Get_Prices_Item_By_ID(ByRef cmd As SqlCommand, ByRef dr As SqlDataReader, ByVal ItemID As Integer) As Integer Dim retval As String cmd = New SqlCommand("Get_Prices_Item_By_ID") daa.SelectCommand.Parameters.AddWithValue("@FirstUnitWholeSalePrice", SqlDbType.Decimal) daa.SelectCommand.Parameters.AddWithValue("@FirstUnitShopperPrice", SqlDbType.Decimal) daa.SelectCommand.Parameters.AddWithValue("@FirstUnitDemotionsPrice", SqlDbType.Decimal) daa.SelectCommand.Parameters.AddWithValue("@FirstUnitPriceDefult", SqlDbType.Bit) daa.SelectCommand.Parameters.AddWithValue("@SecondUnitWholeSalePrice", SqlDbType.Decimal) daa.SelectCommand.Parameters.AddWithValue("@SecondUnitShopperPrice", SqlDbType.Decimal) daa.SelectCommand.Parameters.AddWithValue("@SecondUnitDemotionsPrice", SqlDbType.Decimal) daa.SelectCommand.Parameters.AddWithValue("@SecondUnitPriceDefult", SqlDbType.Bit) daa.SelectCommand.Parameters.AddWithValue("@ThirdUnitWholeSalePrice", SqlDbType.Decimal) daa.SelectCommand.Parameters.AddWithValue("@ThirdUnitShopperPrice", SqlDbType.Decimal) daa.SelectCommand.Parameters.AddWithValue("@ThirdUnitDemotionsPrice", SqlDbType.Decimal) daa.SelectCommand.Parameters.AddWithValue("@ThirdUnitPriceDefult", SqlDbType.Bit) daa.SelectCommand.Parameters.AddWithValue("@DefultPrice", SqlDbType.Int) dr = cmd.ExecuteReader() Return retval End Function
Code:Public Function Get_Prices_Item_By_ID(ByVal ItemID As Integer) As DataTable Dim dt As New DataTable p.Get_Prices_Item_By_ID(dt) Return dt End Function
What Code I have to Put in search Button ?
And How To Display Record From SQL To TextBox ?




Reply With Quote
