将数据类型nvarchar转换为bigint时出错 [英] Error converting data type nvarchar to bigint

查看:778
本文介绍了将数据类型nvarchar转换为bigint时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过提供id和名称来搜索数据库中的数据。通过提供id,我可以获取数据,但通过使用名称显示错误错误将数据类型nvarchar转换为bigint



我尝试了什么:



i也尝试了类似关键字,但它不起作用

解决方案

因此,逻辑是,您不能将字符串值传递给 BigInt 字段,因为您正在执行name,这不是整数值。相反,你必须传递一个Integer值,否则将其转换为Integer。

 cmd.Parameters.AddWithValue(@ name,Convert.ToInt64(someValue)); 



如果您想按名称进行数据过滤,只需将数据库列数据类型从 BigInt 更改为为nvarchar(100)


i am trying to search data in database by providing id and name. by providing id i can able to get data but by using name is show error "error converting data type nvarchar to bigint"

What I have tried:

i have try like keyword also but it was not workin

解决方案

Thus, the logic is, you can't pass string value to a BigInt field as you are doing "name", which is not an Integer value. Instead you have to pass one Integer value, else convert it to Integer.

cmd.Parameters.AddWithValue("@name", Convert.ToInt64(someValue));


and if you want to get data filtering by name, simply just change your database column data type from BigInt to nvarchar(100).


这篇关于将数据类型nvarchar转换为bigint时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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