Feb 11, 2009

selecting two different table values in multiple column unmatching in sqlserver

create a temp table to view unmatched fields from first table

create table #zip(
City varchar(100)collate Latin1_General_CI_AS,
State varchar(100)collate Latin1_General_CI_AS,
County varchar(100)collate Latin1_General_CI_AS)


declare @City varchar(100)
declare @State varchar(100)
declare @County varchar(100)

declare @City1 varchar(100)
-- declare @State1 varchar(100)
-- declare @County1 varchar(100)
DECLARE
c3 CURSOR FOR
select distinct City,
State,
County from T_Companies
OPEN c3
FETCH next FROM c3 INTO @City,@State,@County
WHILE @@FETCH_status=0
BEGIN
SET @City1=''
--insert into #zip
select @City1='1'
from T_Zipcodes where City=@City
and State=@State and County=@County
IF @City1 !='1'
BEGIN

insert into #zip
SELECT @City,@State,@County
END


FETCH next FROM c3 INTO @City,@State,@County
END
CLOSE c3
DEALLOCATE c3

select * from #zip

drop table #zip

Feb 5, 2009

Feb 4, 2009

Dropdown list values get from DB in ASP.net

in .cs file code
------------------
public DataSet LoadValues(string procName, string valueField, string nameField)
{
string retVal = string.Empty;
DataSet ds = new DataSet();
if (procName == "GetList" || procName == "GetStateName")
{
retVal = "";
}
ds = GetStateValues(procName);
// now construct the option list
if (ds != null)
{
if (ds.Tables[0].Rows.Count > 0)
{
for (int x = 0; x < ds.Tables[0].Rows.Count; x++) { retVal += "";
}
}
}

return ds;
}
===========
code hehind section add the below code:
--------------------------------------
SessionDB sessionDB = new SessionDB();

DataSet ds = sessionDB.LoadValues("GetList", "UserID", "UserName");

if (ds.Tables[0].Rows.Count > 0)
{
dduserid.DataSource = ds.Tables[0];
dduserid.DataTextField = "UserName";
dduserid.DataValueField = "UserName";
dduserid.DataBind();
dduserid.Items.Insert(0, "----Select----");
}

Jan 28, 2009

select columns from three different tables using join in sqlserver 2005

--Select values from 3 diff tables
---------------------------------
SELECT DISTINCT A.NAICS,B.NAICSS,C.SIC

FROM #NAICS A JOIN NAIC_SIC..NAICS B ON

A.[NAICS]=SUBSTRING(CAST(B.NAICS AS VARCHAR),1,5)

JOIN [LE-NAICS] C ON

A.[NAICS]=C.NAICS

Jan 23, 2009

Hide menus in master page using asp.net

if (Request.QueryString["hid"] != null)
{
if (Request.QueryString["hid"] == "hidelink")
{
_master.ShowHideLinks("hidelinkedarea");
}
}

send this QueryString whenever you need to hide
sample : Response.Redirect("SearchDetails.aspx?cid=" + compid + "&hid=hidelink");