Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My data base table is this
SQL
CREATE TABLE [dbo].[tbl_binary7](
    [sno_no] [int] IDENTITY(1,1) NOT NULL,
    [sponser_id] [numeric](10, 0) NULL,
    [ibo_id] [numeric](10, 0) NULL,
    [placement] [int] NULL,
    [ibo_title] [nchar](10) NULL,
    [ibo_fname] [nvarchar](50) NULL,
    [ibo_lname] [nvarchar](50) NULL,
    [ibo_dob] [datetime] NULL,
    [cibo_title] [nchar](10) NULL,
    [cibo_fname] [nvarchar](50) NULL,
    [cibo_lname] [nvarchar](50) NULL,
    [cibo_dob] [datetime] NULL,
    [address1] [nvarchar](50) NULL,
    [address2] [nvarchar](50) NULL,
    [state] [nvarchar](50) NULL,
    [city] [nvarchar](50) NULL,
    [panno] [nvarchar](12) NULL,
    [pincode] [numeric](10, 0) NULL,
    [mob] [numeric](10, 0) NULL,
    [email] [nvarchar](50) NULL,
    [bankName] [nvarchar](50) NULL,
    [acc_no] [nvarchar](50) NULL,
    [ifsc_code] [nvarchar](50) NULL,
    [appling] [numeric](10, 0) NULL,
    [doj] [datetime] NULL,
    [abc] [nvarchar](50) NULL,
    [xyz] [nvarchar](50) NULL,
 CONSTRAINT [PK_tbl_binary7] PRIMARY KEY CLUSTERED
(
    [sno_no] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]




My store procedure is this
C#
ALTER PROCEDURE [dbo].[sp_InsertIBO]
	(
	@sponser_id  varchar(50),
	@ibo_id   varchar(50),
    @placement nvarchar(5),
    @ibo_title  nchar(10),
    @ibo_fname nvarchar(50),
    @ibo_lnamer nvarchar(50),
    @ibo_dob Datetime,
    @cibo_title nchar(10),
    @cibo_fname nvarchar(50),
    @cibo_lname nvarchar(50),
   -- @cibo_dob   datetime,
    @address1 nvarchar(50),
    @address2 nvarchar(50),
    @state nvarchar(50),
    @city nvarchar(50),
    @panno nvarchar(50),
    @pincode varchar(50), 
    @mob nvarchar(50),
    @email nvarchar(50),
    @bankName nvarchar(50),
    @acc_no nvarchar(50),
    @ifsc_code  nvarchar(50),
    @doj  datetime
	)
AS
BEGIN
	 insert into tbl_binary7
	 (
	 sponser_id,
	ibo_id,
    placement,
    ibo_title,
    ibo_fname,
    ibo_lname,
    ibo_dob,
    cibo_title, 
    cibo_fname,
    cibo_lname, 
   -- cibo_dob,
    address1,
    address2,
    state,
    city,
    panno,
    pincode, 
    mob, 
    email,
    bankName,
    acc_no,
    ifsc_code,
    doj
	  )
	  values
	  (
	  @sponser_id ,
	@ibo_id,
    @placement,
    @ibo_title,
    @ibo_fname,
    @ibo_lnamer,
    @ibo_dob,
    @cibo_title, 
    @cibo_fname,
    @cibo_lname, 
  --  @cibo_dob,
    @address1,
    @address2,
    @state,
    @city,
    @panno,
    @pincode, 
    @mob, 
    @email,
    @bankName,
    @acc_no,
    @ifsc_code,
    @doj
	  );
END
Posted
Updated 30-Apr-14 20:25pm
v2

The obvious answer is: "don't try to insert strings into a numeric field".

If you need it to be numeric - and you do, or you wouldn't have created it as a numeric field in the first place - then it can only hold numeric values. So validate your inputs and only allow numbers.

The other possibility is that your "mob" column is supposed to be a mobile phone number - and that is not a number, because you can't do math with phone numbers, and they can contain "strange" characters such as country code identifiers, spaces, and so forth.
 
Share this answer
 
Comments
Maciej Los 1-May-14 14:55pm    
5ed!
1M reputation - WOW! Congrats!
OriginalGriff 1-May-14 15:13pm    
Thank you!
It looks a touch 'odd', but I guess I'll get used to it! :laugh:
Matt T Heffron 1-May-14 16:14pm    
+5
Replace:
SQL
@mob nvarchar(50),

with
SQL
@mob numeric(10,0),

and pass proper numeric value into SP

;)
 
Share this answer
 
Convert the string to a numeric value before inserting into the database.
Use Convert.ToDecimal or Decimal.TryParse.

Or else, change the database field type to string.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900