“'RCountry'列不属于表格Table。'

时间:2019-02-15 04:44:43

标签: c# asp.net sql-server

问题在我的雇员视图页面中,我有一个选项称为“编辑”,它会转到新页面以在此处编辑雇员的详细信息。我正在使用此行将数据从sql server获取到文本框,并显示此信息错误,我已经多次检查列名称地狱,但我不知道错误在哪里。我一直在使用存储过程从数据库中获取价值

我拥有所有的过程,没有一个能帮助我。

txtrcountry.Text = dtst.Tables[0].Rows[0]["RCountry"].ToString();

这是我的存储过程,用于将编辑后的数据插入数据库

USE [PMS v1.0]
GO
/****** Object:  StoredProcedure [dbo].[editemp]    Script Date: 15-02-2019           09:54:19 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER procedure [dbo].[editemp](@empid int )

as
begin
select Employeeid,firstname,lastname,Gender,convert(varchar(20),(convert(date,DateofBirthday,105))) as  DateofBirthday,Mobilenumber,
Alternatenumber,Emailid,AlternateEmail,Fathername,
Mothername,AadhaarCardNo,PanCardNo,PassportNo,UserName,Password,RAddressLine1,RAddressLine2,RCity,RState,RZipCode,RCountry,
PAddressLine1,PAddressLine2,PCity,PState,PZipCode,PCountry,OAddressLine1,
OAddressLine2,OCity,OState,OZipCode,OCountry from newemployee with(nolock)    where Employeeid=@empid 
select sno,Employeeid,languagename,Expertise from employeelanguges  with(nolock) where Employeeid=@empid 
end

这是另一个用于从数据库获取数据的存储过程

USE [PMS v1.0]
GO
/****** Object:  StoredProcedure [dbo].[anotherpageupdateemp]    ScriptDate: 15-02-2019 09:57:36 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[anotherpageupdateemp]
(
@Employeeid int,@firstname nvarchar(20),@lastname nvarchar(40),@Gender nvarchar(10),@DateOfBirth nvarchar(20),
@Fathername nvarchar(20),@Mothername nvarchar(20),
@Emailid nvarchar(20),@AlternateEmail nvarchar(20),@AadhaarCardNo nvarchar(20),
@PanCardNo nvarchar(20),@PassportNo nvarchar(20),@UserName nvarchar(20),
@Password nvarchar(20),@Mobilenumber nvarchar(20),@Alternatenumber nvarchar(20),@RAddressLine1 nvarchar(40),
@RAddressLine2 nvarchar(40),@RCity nvarchar(30),@RState nvarchar(30),@RZipCode nvarchar(20),@RCountry nvarchar(30),
@PAddressLine1 nvarchar(30),@PAddressLine2 nvarchar(30),
@PCity nvarchar(20),@PState nvarchar(20),@PZipCode nvarchar(20),@PCountry nvarchar(30),@OAddressLine1 nvarchar(30),@OAddressLine2 nvarchar(30),@OCity nvarchar(20),
@OState nvarchar(20),@OZipCode nvarchar(20),@OCountry nvarchar(30)
)
as
begin
update newemployee set firstname=@firstname,lastname=@lastname,Gender=@Gender,DateofBirthday=@DateOfBirth,Fathername=@Fathername,Mothername=@Mothername,
Emailid=@Emailid,AlternateEmail=@AlternateEmail,AadhaarCardNo=@AadhaarCardNo,PanCardNo=@PanCardNo,PassportNo=@PassportNo,UserName=@UserName,
Password=@Password,Mobilenumber=@Mobilenumber,Alternatenumber=@Alternatenumber,RAddressLine1=@RAddressLine1,
 RAddressLine2=@RAddressLine2,RCity=@RCity,RState=@RState,RZipCode=@RZipCode,RCountry=@RCountry,PAddressLine1=@PAddressLine1,PAddressLine2=@PAddressLine2,
PCity=@PCity,PState=@PState,PZipCode=@PZipCode,PCountry=@PCountry,OAddressLine1=@OAddressLine1,OAddressLine2=@OAddressLine2,OCity=@OCity,OState=@OState,OZipCode=@OZipCode,OCountry=@OCountry

where Employeeid=@Employeeid
end

txtrcountry是文本框ID,RCountry是列名,我应该在文本框中获取国家的详细信息。

2 个答案:

答案 0 :(得分:0)

您在C#端中的参数数量与存储过程不同。您的参数应如下所示:

  • @Employeeid
  • @名字
  • @姓氏
  • @性别
  • @DateOfBirth
  • @父亲名
  • @母亲名
  • @Emailid
  • @AlternateEmail
  • @AadhaarCardNo
  • @PanCardNo
  • @PassportNo
  • @UserName
  • @密码
  • @Mobilenumber
  • @Alternatenumber
  • @ RAddressLine1
  • @ RAddressLine2
  • @RCity
  • @RState
  • @RZipCode
  • @RCountry
  • @ PAddressLine1
  • @ PAddressLine2
  • @PCity
  • @PState
  • @PZipCode
  • @PCountry
  • @ OAddressLine1
  • @ OAddressLine2
  • @OCity
  • @OState
  • @OZipCode
  • @OCountry

答案 1 :(得分:0)

是的,我已经解决了整个错误谢谢@GaganDeep和@Gauravsa帮助我解决了该错误

我在C#代码中传递了一个额外的参数

cmd.Parameters.AddWithValue("@Role", empenty.Role);

我删除了此行,此行解决了我的错误