473,395 Members | 1,931 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to fix "Syntax error in INSERT INTO statement" using OLEDB?

hi I am working on an application that manages the data in a access database. but i cant seem to get past this error.

When i try to run it it says:
"Syntax error in INSERT INTO statement" syntax error, I have made all the fields in database TEXT(255) so it cant be that.

any help regarding this will be much appreciated, i am new to datasets and would love any help or guides i can get on the matter.

Expand|Select|Wrap|Line Numbers
  1.                                                         string connstring = "Provider=Microsoft.Jet.OleDb.4.0;" +
  2.                                                                         @"Data Source=" + DBpath + ";" + "Jet OLEDB:Database Password=password;";
  3.                                                         OleDbConnection conn = new OleDbConnection(connstring);
  4.                                                         conn.Open();
  5.  
  6.                                                         OleDbDataAdapter dba = new OleDbDataAdapter("Select * FROM Teachers", conn);
  7.                                                         OleDbCommandBuilder cmdBuilder = new OleDbCommandBuilder(dba);
  8.                                                         DataSet ds = new DataSet();
  9.                                                         dba.Fill(ds, "Teachers");
  10.                                                         DataTable dt = ds.Tables["Teachers"];
  11.                                                         DataRow studentRow = dt.NewRow();
  12.                                                         studentRow["TeachNo"] = "2";
  13.                                                         studentRow["TName"] = textBox1.Text;
  14.                                                         studentRow["TSurname"] = textBox2.Text;
  15.                                                         studentRow["Gender"] = comboBox1.Text;
  16.                                                         studentRow["Age"] = textBox3.Text;
  17.                                                         studentRow["Cell-No"] = textBox6.Text;
  18.                                                         studentRow["Tell-No"] = textBox5.Text;
  19.                                                         studentRow["Suburb"] = textBox9.Text;
  20.                                                         studentRow["Street-address"] = textBox11.Text;
  21.                                                         studentRow["E-Mail"] = textBox13.Text;
  22.                                                         dt.Rows.Add(studentRow);
  23.  
  24.  
  25.                                                         dba.Update(ds, "Teachers");
  26.                                                         conn.Close();
  27.                                                         //Save to Teacher
  28.  
My using statements:
Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.Data.OleDb;
  10.  
any help would be much appreciated
Jan 22 '11 #1
0 1616

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Oliver Spiesshofer | last post by:
Hi, I have a script that calls an fopen() on an external URL. I can run the script from the server as an url fine. When however the script should be run from crontab, it does not work. I get ...
5
by: Catherine | last post by:
I am having a problem viewing asp pages on iis version 5.1 xp pro. HTML pages are viewable on http://localhost but .asp pages are not. I have created a test program called timetest.asp with the...
19
by: Allen Thompson | last post by:
sorry for the simple question, haven't done this in a while. when I use the following script it keeps displaying the value of "x" like a string. for example, if I type the number 7 in the prompt,...
0
by: Sebastian Sosna | last post by:
Hi there! iam trying a code snippet from MSDN heres the link : http://msdn.microsoft.com/library/default.asp?url=/library/en-us/netdir/netds/creating_groups.asp ive tried the code but it...
7
by: Christine | last post by:
My code has a split function that should split the text file of numbers. I've run this in previous programs as it is here and it worked, but now it wont work for some reason and returns...
1
by: Gary | last post by:
I have the following in my web.config.... <customErrors mode="RemoteOnly" defaultRedirect="Applicationerror.aspx"/> but, my error page does not display. Instead a 'Runtime Error' page...
9
by: Woody Splawn | last post by:
I have a form based on a dataset containing two tables. When I issue an update for the dataset it works when I issue it for one table but not for the other. In the second instance I modify a...
9
by: Kevin Hodgson | last post by:
I'm experiencing a strange Dataset Update problem with my application. I have a dataset which has a table holding a set of customer information records. (address, contact, info, etc.) I have a...
1
by: Krish2007 | last post by:
Hi, Consider the following scenario I have a Database source i had filled in my dataset with the help of Dataadapter after working on the dataset i want the data source to be updated back with...
7
by: Ivan Jericevich | last post by:
For some reason the update does not change the data in the database. It was working fine before, I checked that the bindingsource and tableadapter are still on the form....what else could be wrong?...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.