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
Marvin kakuru
1.3k
362
161.7k
Insert into access 2007 database
Mar 11 2012 1:24 PM
Hi everyone
I am trying to use the code below to insert data into my access database, in the database I have set wkno and yr values as "number" and dat as "date/time" all the rest are set as "text" values. When I run the code below I get an error "Syntax error in INSERT INTO statement."
DateTime date = Convert.ToDateTime(textBox4.Text);
OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\katoto\Documents\Visual Studio 2010\Projects\Genesis Philcollins\data\thyfarm.accdb;Jet OLEDB:Database Password=Kyozi");
conn.Open();
string insertString = "insert into Herdregistar (day,dat,wkno,mont,yr,motheruic,mother,animalsex,uic,nam,tagno,status,owner,presence) values ('" + textBox3.Text + "','" + DateTime.Parse(textBox4.Text).ToString("dd/MM/yyyy") + "','" + textBox5.Text + "','" + textBox6.Text + "','" + textBox7.Text + "','" + textBox8.Text + "','" + textBox9.Text + "','" + comboBox3.Text + "','" + textBox11.Text + "','" + textBox12.Text + "','" + textBox13.Text + "','" + comboBox1.Text + "','" + textBox15.Text + "','" + comboBox4.Text + "')";
OleDbCommand cmd = new OleDbCommand(insertString, conn);
cmd.ExecuteNonQuery();
conn.Close();
please help me.
thanks
Reply
Answers (
3
)
Error with labels
"Unable to cast object of type 'System.Web.UI.WebControls.DataGridLinkButton" error