CS0029:无法将类型'int'隐式转换为'string'此错误显示ON = -S.INSERT(“INSERTTBLEMPLOYEEDETAIL”)请解除此错误

CS0029:无法将类型'int'隐式转换为'string'此错误显示ON = -S.INSERT(“INSERTTBLEMPLOYEEDETAIL”)请解除此错误

问题描述:

protected void btnsave_Click1(object sender,EventArgs e)

{

assignvalues();



{

x = s.insert(inserttblemployeedetail);

if(x> 0)

{

Interaction.MsgBox(已保存);

}

其他

{

Interaction.Msgbox(未保存);

}

}

}

protected void btnsave_Click1(object sender, EventArgs e)
{
assignvalues();

{
x = s.insert("inserttblemployeedetail");
if (x > 0)
{
Interaction.MsgBox("Saved");
}
else
{
Interaction.Msgbox("Not Saved");
}
}
}

check x的数据类型。它看起来像insert方法返回int并且你试图将它存储在字符串中
check data types for x. it looks like insert method is returning int and you are trying to store it in string


因为insert函数返回类型与变量x不匹配..
Because insert function return type not match with variable x..


该消息解释了错误。如果您尝试将整数值存储在字符串中,则此错误非常明显。



The message explains the error. This error quite obvious if you are trying to store an Integer Value in an string.

关注是你的代码中的检查点:
Following are checkpoint here in your code:

1。如果 s.insert 返回整数那么变量 x 应该是一个整数

2.如果 s.insert 返回字符串然后变量 x 应为字符串

1. If s.insert is returning Integer then variable x should be an Integer.
2. If s.insert is returning String then variable x should be a String.







试试这个:




Try this:

int x = s.insert("inserttblemployeedetail");
if (x > 0)
{
    Interaction.MsgBox("Saved");
}
else
{
    Interaction.Msgbox("Not Saved&");
}







- Amit