ALTER PROCEDURE dbo.search_and_and
@fname varchar(35),
@lname varchar(35)
-- @city_id int
AS
Begin
select registration.user_id as 'Id' ,registration.sname as 'Name',
registration.fname as 'First Name', registration.mname as 'Middle Name', registration.lname as 'Last Name', registration.address as 'Address',
city.city_name as 'City', state.state_name as 'State',registration.bdate as 'Bdate',registration.gotra as 'Gotra',
registration.pincode as 'Pincode', registration.occupation as 'Occupation', registration.membership as 'Membership',
registration.blood_id as 'Blood Group' from registration inner join city
ON registration.city_id = city.city_id inner join state
ON registration.state_id = state.state_id AND city.state_id = state.state_id
WHERE (registration.fname =@fname) AND (registration.lname = @lname) --AND registration.city_id = @city_id
End
RETURN
dis is my code to search according to firstname and lastname
if (select1 == "AND" && select2 == "AND")
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@fname", cmbmemfname.SelectedText.Trim());
cmd.Parameters.AddWithValue("@lname", cmbmemlname.SelectedText);
// cmd.Parameters.AddWithValue("@city_id", cmbmemcity.SelectedValue);
SqlDataAdapter memfnameda = new SqlDataAdapter(cmd);
DataTable memfnamedt = new DataTable();
memfnameda.Fill(memfnamedt);
dgridregistration.DataSource = memfnamedt;
this is my code to search.
and
SqlDataAdapter fnameda = new SqlDataAdapter(" select fname,user_id from registration", con);
DataTable fnamedt = new DataTable();
cmbmemfname.DataSource = fnamedt;
fnameda.Fill(fnamedt);
cmbmemfname.DisplayMember = "fname";
cmbmemfname.ValueMember = "user_id";
cmbmemfname.DropDownStyle = ComboBoxStyle.DropDownList;
and the above code to fill the combobox which have firstname
i have tested this query this is ok. but when i leave a space before firstname.
but i don't understand why dis is so.
i also tried
'' + @fname
in sql query. but this is also not working