Internet is growing Every Seconds :: Industry is growing Every Year

Sunday, February 27, 2005

ASP Function : getmc_ColumnValue

Description

This method is used to get the specified column value
It accepts 5 arguments namely, TableName, FieldName, KeyName,
KeyValue and datatype
TableName – Name of the table
FieldName – Name of the Field
KeyName – Name of the Column Name used to filter the table.
Keyvalue – value used in the filter
KeyName should be Primary key.
Datatype – Datatype of the keyname.


ASP code

Set Con = Server.CreateObject("ADODB.Connection")
CON.ConnectionString ="Provider=SQLOLEDB.1;User
Id="NB_USERiD";password="NB_PASSWORD";Persist Security
Info=False;Initial Catalog=hol_sinar;Data Source="sYSTEM NAME";"
Con.open
Public Function
getmc_ColumnValue(TableName,FieldName,KeyName,KeyValue,datatype)
Colvalue=""
set bn_rskey = Server.CreateObject("ADODB.RecordSet")
if datatype="I" then 'for integer keyfield
sql = "select "&FieldName&" as Colvalue from "&TableName& " WHERE
"&KeyName& "="&Keyvalue
else 'for character keyfield
sql = "select "&FieldName&" as Colvalue from "&TableName& " WHERE
"&KeyName& "='"&Keyvalue&"'"
end if
bn_rskey.open sql,Con
if not bn_rskey.eof then
ColValue = bn_rskey("Colvalue")
end if
bn_rskey.close
set bn_rskey=Nothing

getmc_ColumnValue=ColValue
End Function

getmc_ColumnValue("Tbl_user","usr_nme","usr_id",1,"I")
getmc_ColumnValue("Tbl_user","usr_nme","usr_nme","Raja","C")

Wednesday, February 23, 2005

ASP Function : mcn_RecordExists

Description

This method is used to find the specified Record Exists in the table.
This accepts 4 arguments namely, TableName, FieldName, FieldValue and
Datatype.
TableName – Name of the table
FieldName – Name of the Field
Fieldvalue – value of the field
Datatype – Datatype of the Fieldname.

ASP code

Set Con = Server.CreateObject("ADODB.Connection")
CON.ConnectionString ="Provider=SQLOLEDB.1;User
Id="NB_USERiD";password="NB_PASSWORD";Persist Security
Info=False;Initial Catalog=hol_sinar;Data Source="sYSTEM NAME";"
Con.open

Public Function
mcn_RecordExists(TableName,fieldname,fieldvalue,datatype)
'----- check record exists in table or not -------
Set mcn_rs1 = Server.CreateObject("ADODB.recordSet")
sql = "select * from "&TableName&" where "
if datatype="C" then
sql = sql & fieldname&" ='" &fieldvalue& "'"
elseif datatype="I" then
sql = sql & fieldname&" =" &fieldvalue& ""
end if

mcn_rs1.Open sql,Con
if not mcn_rs1.EOF then
retn = True
else
retn = False
end if
mcn_rs1.Close
set mcn_rs1=Nothing
mcn_RecordExists = retn
End Function



Public Function
mcn_RecExis_2fld(TableName,fieldname1,fieldvalue1,datatype1,fieldname2,fieldvalue2,datatype2)
'----- check record exists in table or not -------
Set mcn_rs1 = Server.CreateObject("ADODB.recordSet")
sql = "select * from "&TableName&" where "
if datatype1="C" then
sql = sql & fieldname1&" ='" &fieldvalue1& "' and "
elseif datatype1="I" then
sql = sql & fieldname1&" =" &fieldvalue1& ", and "
end if

if datatype2="C" then
sql = sql & fieldname2&" ='" &fieldvalue2& "'"
elseif datatype2="I" then
sql = sql & fieldname2&" =" &fieldvalue2& ""
end if



'Response.Write sql
'Response.End
mcn_rs1.Open sql,Con
if not mcn_rs1.EOF then
retn = True
else
retn = False
end if
'Response.Write mcn_rs1(0)
'Response.End
mcn_rs1.Close
set mcn_rs1=Nothing
mcn_RecExis_2fld = retn
End Function



Public Function
mcn_RecExis_3fld(TableName,fieldname1,fieldvalue1,datatype1,fieldname2,fieldvalue2,datatype2,fieldname3,fieldvalue3,datatype3

)
'----- check record exists in table or not -------
Set mcn_rs1 = Server.CreateObject("ADODB.recordSet")
sql = "select * from "&TableName&" where "
if datatype1="C" then
sql = sql & fieldname1&" ='" &fieldvalue1& "' and "
elseif datatype1="I" then
sql = sql & fieldname1&" =" &fieldvalue1& " and "
end if

if datatype2="C" then
sql = sql & fieldname2&" ='" &fieldvalue2& "' and "
elseif datatype2="I" then
sql = sql & fieldname2&" =" &fieldvalue2& " and "
end if

if datatype3="C" then
sql = sql & fieldname3&" ='" &fieldvalue3& "'"
elseif datatype2="I" then
sql = sql & fieldname3&" =" &fieldvalue3& ""
end if


'Response.Write sql
'Response.End
mcn_rs1.Open sql,Con
if not mcn_rs1.EOF then
retn = True
else
retn = False
end if
'Response.Write mcn_rs1(0)
'Response.End
mcn_rs1.Close
set mcn_rs1=Nothing
mcn_RecExis_3fld = retn
End Function

Sunday, February 20, 2005

ASP Function : cbo_lst_vluId_showName_nb

Description

This method is used to Fill the combo box when the page is refreshed
and its maintain the same data.

This accepts 10
TableName,cmbovaluefld,comboshow,orderby_name,do_sub,slt_fld_id,wer_cond,wer_KeyName,wer_KeyValue,wer_datatype
TableName - Name of the Table name
cmbovaluefld - name of the Combobox value < option value=
cmbovaluefld >
comboshow -name of the Combobox Showing Field < option value=
cmbovaluefld > comboshow < / option >
orderby_name -display the Names in Order by in SQL Query
do_sub - yes or no wheater its submit or not
slt_fld_id - if the page is submited the submited value is selected
after the refreshing
wer_cond - if the submited value is checked any ohter values (its
true or false)
wer_KeyName -Name of the Field
wer_KeyValue-value of the field
wer_datatype- Datatype of the Fieldname.

ASP Code


Public Function
cbo_lst_vluId_showName_nb(TableName,cmbovaluefld,comboshow,orderby_name,do_sub,slt_fld_id,wer_cond,wer_KeyName,wer_KeyValue,w

er_datatype)
ColValue=""
ck_val_nb=1
set cbo_rs = Server.CreateObject("ADODB.RecordSet")
if wer_cond="yes" and wer_datatype="I" then
sql = "select "&cmbovaluefld&" as optvalue , "&comboshow&" as
optshow from "&TableName& " where "&wer_KeyName& "="&wer_KeyValue &"
ORDER BY "&orderby_name&""
elseif wer_cond="yes" and wer_datatype="S" then
sql = "select "&cmbovaluefld&" as optvalue , "&comboshow&" as
optshow from "&TableName& " where "&wer_KeyName& "='"&wer_KeyValue
&"'" &" ORDER BY "&orderby_name&""
else
sql = "select "&cmbovaluefld&" as optvalue , "&comboshow&" as
optshow from "&TableName& " ORDER BY "& orderby_name&""
end if

cbo_rs.open sql,Con
if not cbo_rs.eof then
while not cbo_rs.EOF

if do_sub="no" then
if ck_val_nb=1 then
ck_nb_sel_val="Selected"
else
ck_nb_sel_val=""
end if
ColValue=ColValue & " < OPTION value="&cbo_rs("optvalue") &"
"& ck_nb_sel_val&" > "& cbo_rs("optshow") &" < / option > "
ck_val_nb=ck_val_nb+1

elseif do_sub="yes" and slt_fld_id="" then
if ck_val_nb=1 then
ck_nb_sel_val="Selected"
ColValue=ColValue & " < OPTION value=selectanyone selected >
Select any one < /option > "
ck_nb_sel_val=""
else
ck_nb_sel_val=""
end if
ColValue=ColValue & " < OPTION value="&cbo_rs("optvalue") &"
"& ck_nb_sel_val&" > "& cbo_rs("optshow") &" < / option > "
ck_val_nb=ck_val_nb+1

elseif do_sub="yes" and slt_fld_id < > "" then
if ck_val_nb=1 and cint(slt_fld_id)=cint(cbo_rs("optvalue")) then
ck_nb_sel_val="Selected"
ck_val_nb=ck_val_nb+1
else
ck_nb_sel_val=""
end if
ColValue=ColValue & " < OPTION value="&cbo_rs("optvalue") &"
"& ck_nb_sel_val &" > "& cbo_rs("optshow") &" < /option > "
end if
cbo_rs.MoveNext
wend
else
ColValue=ColValue & " < PTION selected value=0 > Datas Not
Available < option "
end if
cbo_rs.close
set cbo_rs=Nothing
cbo_lst_vluId_showName_nb=ColValue
End Function





< TR > < TD > Project Name < /td > < TD colspan=3 >
< SELECT NAME="project" onchange="proj_submit()" >
< %
slt_fld_id=trim(Request.Form("project"))
dosub="yes"
% >
<
%=cbo_lst_vluId_showName_nb("Tbl_Proj_Master","Project_ID","Project_Name","Project_Name",dosub,slt_fld_id,0,0,0,0)%
>
< /SELECT > < /TD >
< /tr >








< tr > < TD > Employee Name < /TD > < TD colspan=3 >

< SELECT name="empid" style="width: 250px;" onchange="proj_submit()"
>
< %
empid=trim(request.Form("empid"))
dosub="yes"
wer_cond="yes"
wer_KeyName="Project_ID"
if slt_fld_id="" then slt_fld_id=0
wer_KeyValue=slt_fld_id
wer_datatype="I"
slt_fld_id=empid
dim chkvalue_nb
chkvalue_nb=0
% >
<
%=cbo_lst_vluId_showName_nb("Tbl_Emp_Master","Emp_ID","emp_name","emp_name",dosub,slt_fld_id,wer_cond,wer_KeyName,wer_KeyValu

e,wer_datatype)%
>
< /SELECT >
< /TD > < /TR >

Wednesday, February 16, 2005

Javascript: Key press Client side validation

Description:

This function is used to control the user can
only entered the number in textbox. On key press Event is occurred when
the
user enter the data in this text box (m_phno). If the user press the
integer
value 1 in this textbox the num_only()function is called .
event.keyCode return
the values is 48.So this function return the True and its accepts this
letter
otherwise return false and values is not entered in Text box.



Code


< script Language="JavaScript" >
function num_only()
{
//alert (event.keyCode);
if (event.keyCode > 47 && event.keyCode < 58 )
{
return true;
}
else
{
event.keyCode=0;
return false;
}
}

function alpha_char()
{
// alphabet with blankspace
//alert (event.keyCode);
if (event.keyCode>96 && event.keyCode <123)//smal
{
return true;
}

if (event.keyCode>64 && event.keyCode <91) //cabs
{
return true;
}


if (event.keyCode==32) //blankspace
{
return true;
}

event.keyCode=0;
return false;

}


< /script >


< form name=nb_frm >
< INPUT type=text name=m_phno id=m_phno value=""
onkeypress="num_only();" >

< / Form>