in sql i create the table in this table i specify the datatype as an int for three fields such as phonenumber,mobilenumber and annual income.for insertion i used the stored procedure.
in .net cs page i pass the textbox value as a parameter .
cmd.Parameters.Add(
cmd.Parameters[2].Value =
when i used this the error value was either too large or too small for an int error will occur how can i solve this.
Thaks
Convert.ToInt32 (phonenmbr.Text);"@phnmber", SqlDbType.Int);
Jaganathan BantheswaranRank #170 · 14.1K reputationPosted Feb 23, 2011, 8:58 PM EST
Range of the Int in SQL is given below.
int
Range: -2^31 (-2,147,483,648) to 2^31-1 (2,147,483,647)
Space: 4 Bytes
so if you use 9034XXXXXX like this sure you will get error.
Try this.
bigint
Range: -2^63 (-9,223,372,036,854,775,808) to 2^63-1 (9,223,372,036,854,775,807)
Space: 8 Bytes
public string InsertData(Int32 phonenum) { SqlConnection con = (SqlConnection)db.CreateConnection(); con.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "UR_SP"; SqlParameter parameter = new SqlParameter("@phnumber", SqlDbType.BigInt); parameter.Direction = ParameterDirection.Input; parameter.Value = phonenum; SqlParameter[] parameters = new SqlParameter[] { parameter }; cmd.Parameters.Add(parameter); IDataReader reader=cmd.ExecuteReader(); if (reader.Read()) { return reader.GetString(reader.GetOrdinal("COLUMN_NAME")); } return string.Empty; } You should also use the bigint type in database. CREATE PROCEDURE UR_SP ( @phnumber bigint ) AS SET NOCOUNT ON SELECT * FROM YRTABLE WHERE PHNUM = @phnumberkrithika muthukrishnanRank #8,369 · 223 reputationPosted Feb 23, 2011, 9:35 PM EST
ya it works well,i have one more error that is input string was not in a correct format. error will occur,i didn't know why this error will occur.here i specify the datatypes are
field name datatype (Input given)
companyname----->varchar----->south nest
companymailid----->varchar--->[email protected]
phonenmber-------->bigint---->044569874
mobilenumber------>bigint---->987456321
functionalarea----->varchar---->IT
keyskill----->varchar--->.net,sql
qualify----->varchar---->BE,MCA,M.Sc
experience--->nchar--->fresher,1+
annualincome---->int--->2,00,000
description---->varchar---->having good knowledge in sql
location--->varchar---->chennai
lastdate---->date/time--->by using now function it loaded
posteddate--->date/time---->2/2/2011
likewise the inputs are given but why th input string was not in a correct format error will occur.can anyone help me.