HI,
I have 1 listbox named lbCountry
i have inserted each selected value from listbox into database by following code:
in class :
'following is my stored procedure
now i dont know how to fetch data from databse and fill listbox with multiple selected value..
plz give suitable solution..
I have 1 listbox named lbCountry
i have inserted each selected value from listbox into database by following code:
Code:
For iLoop = 0 To lbCountry.Items.Count - 1 ' item selected Dim i As Integer() = New Integer(iLoop) {} If lbCountry.Items(iLoop).Selected Then i(iLoop) = CInt(lbCountry.Items(iLoop).Value.ToString()) objPartnerDetailsInfo.BIntPreferenceId = i(iLoop) objPartnerDetailsInfo.VarPreference = lbCountry.ID objPartnerDetailsInfo.BIntProfileId = Session("ProfileId") objPartnerDetails.Insert(objPartnerDetailsInfo) End If Next
in class :
Code:
Public Sub Insert(ByVal objPartnerDetailsInfo As PartnerDetailsInfo) conn = New SqlConnection(constr) conn.Open() cmd = New SqlCommand("SPAddEditPartnerDetails", conn) cmd.Parameters.Add("@Operation", "Add") cmd.Parameters.Add("@BIntPartnerDetailsId", SqlDbType.BigInt).Value = DBNull.Value cmd.Parameters.Add("@BIntPreferenceId", SqlDbType.BigInt).Value = objPartnerDetailsInfo.BIntPreferenceId cmd.Parameters.Add("@VarPreference", SqlDbType.VarChar).Value = objPartnerDetailsInfo.VarPreference cmd.Parameters.Add("@BIntProfileId", SqlDbType.BigInt).Value = objPartnerDetailsInfo.BIntProfileId cmd.CommandType = CommandType.StoredProcedure cmd.ExecuteNonQuery() cmd.Dispose() conn.Close() End Sub
Code:
ALTER PROCEDURE [dbo].[SPAddEditPartnerDetails] @operation varchar(50), @BIntPartnerDetailsId BIGINT, @BIntProfileId BIGINT, @BIntPreferenceId bigint, @VarPreference varchar(50) AS If @operation ='Add' BEGIN Insert tblPartnerDetails ( BIntProfileId, BIntPreferenceId, VarPreference ) VALUES ( @BIntProfileId, @BIntPreferenceId, @VarPreference ) Select @BIntPartnerDetailsId=@@Identity END
plz give suitable solution..
Comment