473,499 Members | 1,510 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Adding Data to Access DB using OleDb

Hi

Could someone point me in the right direction. Im trying to update an
Access DB using the code below, it seems to all run correctly and I
dont get any error messages, however it doesnt actually add the data
to the table. Any ideas where im going wrong.

private void button1_Click(object sender, EventArgs e)
{

OleDbDataAdapter da = new OleDbDataAdapter("SELECT
[Investment Type],ProjectName,[Extension Size],FinancialYear FROM
InvestmentHistory where [Store ID] = 225",
"Provider=Microsoft.JET.OLEDB.4.0;data source=C:\\Programme DB\
\Investment Programme_be.mdb");
DataSet ds = new DataSet();
da.Fill(ds, "InvestmentHistory");

OleDbConnection connection =
(OleDbConnection)da.SelectCommand.Connection;

DataTable dt = new DataTable("InvestmentHistory");
da.InsertCommand = connection.CreateCommand();
da.InsertCommand.CommandText = "Insert into
InvestmentHistory ([Investment Type],[ProjectName],[Extension Size],
[FinancialYear]) values ('Extension','CNF',2000,0)";

da.InsertCommand.Parameters.Add("Investment Type",
OleDbType.Char, 0, "Store ID");
da.InsertCommand.Parameters.Add("ProjectName",
OleDbType.Char, 0, "ProjectName");
da.InsertCommand.Parameters.Add("Extension Size",
OleDbType.Integer, 0, "Extension Size");
da.InsertCommand.Parameters.Add("FinancialYear",
OleDbType.Integer, 0, "FinancialYear");

da.Update(ds, "InvestmentHistory");
ds.AcceptChanges();
MessageBox.Show("Updated.");
}

There are actually more fields in the table than are being inserted
here, do i need to add default values for them?

Thanks for any suggestions.
Paul

Aug 3 '07 #1
0 1636

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
3447
by: Paul M. | last post by:
Hi, I am trying to add a dataset to a list box on an asp .net page, the query results in about 20 rows coming back when I run it in access but when I loop through the dataset adding each records...
4
409
by: Manish Sawjiani | last post by:
Hi Experts, I am just into dot net and i want simple code for adding records into Access table (97) using oledb. There are no queries in the databases and there is only one table: Friends with...
0
4988
by: Lewt | last post by:
I am aware of the 'hack the registry' approach. This is just not a safe way to accomplish this on a user's PC. I need to do this the right way. Is there anyone -perhaps from Microsoft - out there...
4
3053
by: Will Pittenger | last post by:
I have a project where the backend is Access. I have learned (slowly) to use OLEDB to access my data. However, to save changes, I need to generate a SQL statement. This seems clunky. I am used...
12
3538
by: Art | last post by:
Hi everyone I was hoping someone might be able to help me with this. I'm just starting to try to work with MS Access tables through VB.net. In Access I can take an existing table and add a new...
2
1005
by: zheetee | last post by:
i am beginner to link asp.net and access 2gether i use asp .net matrix...and wrote the Insert data coding Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4;...
8
2541
by: Bonzol | last post by:
Hi there, VB 2003 1.1 Access Database, oledb, Windows Application I've been trying this for 3 days straight now and CANNOT get this to work, im about to go insane because it is soo simple....
7
1771
by: Miro | last post by:
Im a VB Newbie so I hope I'm going about this in the right direction. I have a simple DB that has 1 Table called DBVersion and in that table the column is CurVersion ( String ) Im trying to...
0
7130
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
7007
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...
1
6893
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7386
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
5468
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,...
0
4599
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3098
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3090
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
664
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.