Click here to Skip to main content
15,879,348 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi ,

I am new to .net and i am trying to insert a record into ms access database 2007 from visual studio 2010 using visual c#.
I got an exception stating:
"Oledb exception unhandled"
Object VisitingCard_Insert is not a stored procedure.

I googled a lot and am yet to find the solution .Please can anyone suggest me what to do?

visual studio 2010
ms access database 2007




Code:
C#
public partial class Form1 : Form
   {
        OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Users\\SR050\\Documents\\VisitingCard.accdb");
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            con.Open();
            OleDbCommand cmd = new OleDbCommand("VisitingCard_Insert", con);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@Names", textBox1.Text);
            cmd.Parameters.AddWithValue("@Organization", textBox2.Text);
            cmd.Parameters.AddWithValue("@Location", textBox3.Text);
            cmd.Parameters.AddWithValue("@PhoneNo", textBox4.Text);
            cmd.Parameters.AddWithValue("@EmailId", textBox5.Text);
            int result = cmd.ExecuteNonQuery();
            con.Close();
            if (result > 0)
             {
                MessageBox.Show("Inserted Successfully");
             }
          
         }
   }
Posted
Updated 12-Oct-12 3:12am
v2

1 solution

Did VisitingCard_Insert stored procedure exist in your access database??
 
Share this answer
 
v2
Comments
Sophia Ranjani Elango 12-Oct-12 9:37am    
No VisitingCard_Insert does not have a stored procedure in access database and but i am unable to create stored procedure in ms access 2007
[no name] 12-Oct-12 9:47am    
If you are "unable" to create a stored procedure then change your OleDbCommand to a query.

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