C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » Windows »

Mobile No Inserting problem in ms access db


Posted Date: 31 Oct 2009      Posted By: satheesh      Member Level: Silver     Points: 1   Responses: 1



hi all,
somebody replied my previous question ....Thanks for reply....

I want to insert a record in a table using windows forms(C#). i am trying to insert a record with a mobile no(10 digit) 9999999999. while inserting it
showing error like
Value was either too large or too small for an Int32.

my table fields are like that


Access DB Name = fm.mdb
Table name = tbl_test


Field name Datatype
========== =========
I_id Autonumber
I_Name Text
I_Address Text
I_Mobile Number
I_City Text


Code
=====

private void btn_save Click(object sender, EventArgs e)
{
try
{
con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + AppPath + "fm.mdb");
con.Open();
cmd = new OleDbCommand("Insert into tbl_test(I_name,I_address,I_Mobile,I_City) values('" + fac_name.Text + "','" + fac_address.Text + "'," + '"+ fac_city.Text + "'," + int.Parse(fac_mobile.Text) + ")", con);

cmd.ExecuteNonQuery();
MessageBox.Show("Registered sucessfully...");
}
catch
{

}
finally
{
con.Close();
}
}
can u tell me how to insert
thanks in advance





Responses

Author: MuniHemadriBabu.Jogi    31 Oct 2009Member Level: GoldRating: 2 out of 52 out of 5     Points: 2

Hi

Don't store mobile number as as int, Please use text datatype. because the phone number exceeds int max value in MS access



Post Reply
You must Sign In to post a response.
Next : How to prevent
Previous : Disable mdi menu...
Return to Discussion Forum
Post New Message
Category: Windows

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use