如何验证文本框是否正确从存储过程传递参数 [英] How to validate textbox is correct passing parameter from stored procedure

查看:75
本文介绍了如何验证文本框是否正确从存储过程传递参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个存储过程,在该存储过程中,我传递mobilenumber,assoicateid和加入日期如果有效则会显示该消息有效,否则有效





我的存储过程如下



i created one stored procedure, in that stored procedure i pass mobilenumber,assoicateid and date of joining if it is valid it will shows the message valid else in valid


My Stored Procedure as follows

Declare @isvalid varchar(20)

if Exists (SELECT CAD.[Associate_ID],'mobile' =REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(CRC.Value,'/',''),'-',''),'+91',''),'+',''),' ','')
,convert(varchar(12),CAD.DateOfJoining,101) FROM [CentralRepository].[dbo].[vw_CentralRepository_Contacts] CRC
 join [CentralRepository].[dbo].[vw_CentralRepository_Associate_Details] CAD  on CAD.Associate_ID = CRC.Associate_ID
  WHERE CAD.[Associate_ID]= CRC.[Associate_ID] and Contact_Type ='MBL1' and CRC.[Associate_ID]=@varchar_Associate_ID and  
  ((convert(varchar(12),CAD.DateOfJoining,101)) =@Date_Joining) and
   (@phone= REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(CRC.Value,'/',''),'-',''),'+91',''),'+',''),' ','') ) )
set @isvalid = 'Valid'
Else
set @isvalid = 'InValid'

-----
if(@isvalid = 'InValid')
SELECT 
@isvalid As IsValid,
CASE  when (CAD.[Associate_ID] = @varchar_Associate_ID) then 'Valid'
Else
'InValid'
END AS AssociateCheck
,
CASE When 
( REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(CRC.Value,'/',''),'-',''),'+91',''),'+',''),' ','') =  @phone)
Then 'Valid'
Else
'InValid'
END AS MobileCheck
,
CASE
When (convert(varchar(12),CAD.DateOfJoining,101) = @Date_Joining) 
Then 'Valid'
ELse 'InValid'
End AS DOJCheck
FROM [CentralRepository].[dbo].[vw_CentralRepository_Contacts] CRC
 join [CentralRepository].[dbo].[vw_CentralRepository_Associate_Details] CAD  on CAD.Associate_ID = CRC.Associate_ID
  WHERE CAD.[Associate_ID]= CRC.[Associate_ID] and Contact_Type ='MBL1' and CRC.[Associate_ID]=@varchar_Associate_ID
  else 
  SELECT @isvalid As IsValid 





当我按如下方式执行SP输出时





When i execut the SP output as follows

EXEC [usp_Get_AssociateAuthentication] 176017,'9791234567','10/01/2007'

isvalid
 Valid (Output)





在运行模式下如下



textbox1 textbox2 textbox3提交(按钮)

(mobilenumber)(assoicateid)(加入日期)



在运行模式下,当我输入值为textbox1,textbox2,textbox3时检查值到存储过程参数。如果它匹配,它将显示消息有效



其他无效



我该怎么办asp.net使用c#



我尝试过:



如何验证文本框是否正确从存储过程传递参数



In run mode as follows

textbox1 textbox2 textbox3 Submit(Button)
(mobilenumber) (assoicateid) (date of joining)

in run mode when i type value to textbox1,textbox2,textbox3 it check that value to stored procedure parameter. if it matches it will shows the message valid

else invalid

for that how can i do in asp.net using c#

What I have tried:

how to validate textbox is correct passing parameter from stored procedure

推荐答案

试试这个



try this

SqlConnection con = new SqlConnection("YourConnectionString");
SqlCommand cmd = new SqlCommand("usp_Get_AssociateAuthentication", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@phone",txt_Phone.Text.Trim());
cmd.Parameters.Add("@varchar_Associate_ID", txt_Associate.Text.Trim());
cmd.Parameters.Add("@Date_Joining",   txtDate.Text.Trim());
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
string status = dt.Rows[0][0].ToString();


这篇关于如何验证文本框是否正确从存储过程传递参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆