TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Er Jasvinder Nehal
NA
20
7.9k
Inserting data into ms access database 2007 from visual stud
May 8 2015 12:58 AM
hi
i am new to .net and i am try to Inserting data into ms access database 2007 from visual studio 2005 using c#.net.
i got an error OleDbException was unhanded. Syntax error in INSERT INTO statement.
my code is here
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
using Microsoft.VisualBasic;
namespace WindowsApplication2
{
public partial class Form4 : Form
{
private OleDbConnection cn1;
private OleDbCommand cmd;
private string sql;
private OleDbDataReader reader;
int cnt = 0;
public Form4()
{
cn1 = new OleDbConnection();
cn1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\Users\\hp\\Links\\Documents\\proposed system database\\new ATM Embed Database.mdb";
cn1.Open();
InitializeComponent();
}
private void savebtn_Click(object sender, EventArgs e)
{
Int32 Account_No, PIN_No;
Account_No = Int32.Parse(AccounttextBox.Text);
PIN_No = Int32.Parse(PINtextBox.Text);
sql = "Insert into ATM(C_Name,Account_No,Card_No,PIN_No)values('" + NametextBox.Text + "','" + AccounttextBox.Text + "','" + CardtextBox.Text + "','" + PINtextBox.Text + "',)";
cmd = new OleDbCommand(sql, cn1);
int n =cmd.ExecuteNonQuery();
if (n > 0)
{
MessageBox.Show("Record Has Been Saved !!");
AccounttextBox.Text = "" + (Account_No + 1);
NametextBox.Text = "";
CardtextBox.Text = "";
PINtextBox.Text = "";
}
else
{
MessageBox.Show("Record Not Saved !!");
}
cn1.Close();
}
}
}
Please help me.
suggest me solution of this problem.
Reply
Answers (
3
)
How do I create an intranet Application using C#.net Windows
how to increase value on hashtable?