我正在尝试在我的应用程序中获取我的数据库以通过电话号码进行搜索。我已经进入“搜索条件生成器”屏幕,但我似乎无法正确查询。
这是我尝试过的查询,当我收到“从 nvarchar 转换为数字”错误时:
SELECT phoneNumber, serviceDate, firstName, lastName, billingAddress, emailAddress, vehicleMake, vehicleModel, vehicleYear, vehicleColor, vehicleMileage
FROM [Table]
WHERE (phoneNumber LIKE @phoneNumber + N'%')
这是创建的表:
CREATE TABLE [dbo].[Table] (
[phoneNumber] NUMERIC (18) NOT NULL,
[serviceDate] DATE NULL,
[firstName] NCHAR (10) NULL,
[lastName] NCHAR (10) NULL,
[billingAddress] NVARCHAR (50) NULL,
[emailAddress] NVARCHAR (50) NULL,
[vehicleMake] NCHAR (10) NULL,
[vehicleModel] NCHAR (10) NULL,
[vehicleYear] INT NULL,
[vehicleColor] NCHAR (10) NULL,
[vehicleMileage] INT NULL,
CONSTRAINT [PK_Table] PRIMARY KEY CLUSTERED ([phoneNumber] ASC)
);
如果需要VB代码,我也会提供。