473,563 Members | 2,767 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(o bject sender, EventArgs e)
{

OleDbDataAdapte r da = new OleDbDataAdapte r("SELECT
[Investment Type],ProjectName,[Extension Size],FinancialYear FROM
InvestmentHisto ry where [Store ID] = 225",
"Provider=Micro soft.JET.OLEDB. 4.0;data source=C:\\Prog ramme DB\
\Investment Programme_be.md b");
DataSet ds = new DataSet();
da.Fill(ds, "InvestmentHist ory");

OleDbConnection connection =
(OleDbConnectio n)da.SelectComm and.Connection;

DataTable dt = new DataTable("Inve stmentHistory") ;
da.InsertComman d = connection.Crea teCommand();
da.InsertComman d.CommandText = "Insert into
InvestmentHisto ry ([Investment Type],[ProjectName],[Extension Size],
[FinancialYear]) values ('Extension','C NF',2000,0)";

da.InsertComman d.Parameters.Ad d("Investment Type",
OleDbType.Char, 0, "Store ID");
da.InsertComman d.Parameters.Ad d("ProjectName" ,
OleDbType.Char, 0, "ProjectNam e");
da.InsertComman d.Parameters.Ad d("Extension Size",
OleDbType.Integ er, 0, "Extension Size");
da.InsertComman d.Parameters.Ad d("FinancialYea r",
OleDbType.Integ er, 0, "FinancialYear" );

da.Update(ds, "InvestmentHist ory");
ds.AcceptChange s();
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 1641

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

Similar topics

6
3458
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 field to the list box, the list box only shows the first one and no others. Anyone know whats going on? Thanks Paul Code...
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 the following fields: FriendID (AutoNumber) FirstName, LastName and DateOfBirth Please I have tried everything. WOULD BE HIGHLY OBLIGED for HELP ...
0
5011
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 who can assist me on this? "Colin Stutley" wrote: > I now see your dilemma. > > Not sure of the appropiate API calls, but an alternative may...
4
3063
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 to MFC recordsets. The OleDB system will let me add the row to the rowset, but then does nothing with it. I have tried calling BeginEdit/EndEdit,...
12
3555
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 field with the type AutoNumber. I can then set this up as a key. Then if I go into the table I will see sequential numbers have been inserted into...
2
1011
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; Data Source=C:\Documents an"& _ "d Settings\AliceLee\My Documents\db\equipment.mdb" Dim dbConnection As System.Data.IDbConnection = New...
8
2552
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. All I want to do is insert a new row ! I have 1 table 'People'
7
1779
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 connect to the db, and then add a record to the DBVersion table. Except I cant. I have 1 line that crashes and if i rem it out it works but nothing...
0
7583
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8106
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7950
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6255
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5213
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3643
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1200
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.