473,621 Members | 2,743 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

insert into access database not working.

1 New Member
if i add the sql query straight into access it adds the new row but if i run this function from visual studio it goes through without an error buyt its not adding the new row to the database. please help

private void addtodatabase()
{

OleDbConnection connect = new OleDbConnection (Connection.Con nect());

connect.Open();


for (int count = 0; count <= listView1.Items .Count - 1; count++)
{
int cid = int.Parse(listV iew1.Items[count].SubItems[0].Text);
int pid = int.Parse(listV iew1.Items[count].SubItems[3].Text);
DateTime sday = DateTime.Parse( listView1.Items[count].SubItems[2].Text);
int quantity = int.Parse(listV iew1.Items[count].SubItems[6].Text);
double price = double.Parse(li stView1.Items[count].SubItems[5].Text);
double total = double.Parse(li stView1.Items[count].SubItems[7].Text);

string query = "insert into tblInvoice(Cust omerIDFK,Produc tIDFK,Date,Quan tity,ItemPrice, Total) values("+cid+", "+pid+",#"+sday +"#,"+quantity+ ","+price+","+t otal+")";


OleDbCommand cmd = new OleDbCommand(qu ery, connect);


cmd.ExecuteNonQ uery();


}


connect.Close() ;



Thanks
Aug 10 '10 #1
0 1141

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

Similar topics

0
2942
by: Pato Secruza | last post by:
Hi everyone! I have a really frustrating error and need help. I’m trying to do a function that gets the properties and names of the fields in a MS Access database using ASP. I haven’t programmed in a while so I’m quite lost. Once I have the my database structure I will insert the corresponding fields from a web form but the database is huge and I want to be able to change the database and form without changing the ASP code all the
1
2027
by: Erica | last post by:
Hi, I have searched everywhere, and I can't seem to find the answer to my problem. I am trying to write a very simple piece of ASP code to insert a record into a field in a database. Ultimately it will be for an admin form that takes user input, but for now I just want to get the most intrinsic part working. This is the code: <% ' Declare variables Dim strURL ' The URL of this page so the form will work no matter
5
10273
by: nicholas | last post by:
I would like to insert a new record in a Ms Access database and retrieve the newly created ID (autonumber). I would like to do it in VB.NET for an ASP.NET page. ( no asp) I found several examples on the net, but most of them just work with sql-server (@@indentity), or use just asp with includes etc. Hope someone can help me with a 'working' example...
7
6704
by: Larry B via DotNetMonster.com | last post by:
Hello, I seem to be having a problem with inserting data, from a web form, into an access database. I have tried to do the same thing in a regular windows app, there it works fine, but when I try to do the same thing in an ASP. NET form I get an error saying the 'query needs to be updateable'. The code is identical, except for a little difference in the connection string. Here is my code in the web form, from a button click handler:
6
1401
by: Fred Geurtsen | last post by:
Question about updating a access Database Record! Normally i'm working with SQLserver, but i have to do this with access and it's not working. My error is: Operation must use an updateable query. This is my code: Dim objCommand As OleDbCommand Dim strSQLQuery As String ' Our insert command
0
7708
by: gm | last post by:
Immediately after generating the Access application from the Source Safe project I get: "-2147467259 Could not use ''; file already in use." If Access database closed and then reopened I get: "-2147467259 The database has been place in a state by user 'Admin' on machine ..... that prevents it from being opened or locked."
1
8179
by: Fordraiders | last post by:
vb.net 2003 Office 2003 What I have: C:\TestData\Input.txt Text File Pipe Delimited : 4 columns Of data example: 00001|NO BRAND NAME ASSIGNED|6DU27|M3-.5 X 6 FLAT HD SOCKET CAP SCREW, CL10.9, ALLOY STEEL 00002|NO BRAND NAME ASSIGNED|6DU28|M3-.5 X 8 FLAT HD SOCKET CAP SCREW,
12
2090
by: =?Utf-8?B?Smlt?= | last post by:
I have code that reads and parses a text file using a schema.ini file. Works great. When I see the dataGrid it's exactly what I want. Dim CString As String = _ "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=C:\;" & _ "Extended Properties=""text;HDR=No;""" Dim TConnect As New System.Data.OleDb.OleDbConnection(CString)
0
1905
by: Chuck.Dieterle | last post by:
I have a very frustrating problem. I have a situation that works fine on some computers, but not on others. I have SQL Server Express 2005 and Access 2003 loaded on 4 computers. I have set up a "Linked Server" in SQL Server linked to my Access database. I am running queries on t-SQL against the Access tables through the linked server. On all of the computers, I can do select queries and they all work great but what I need to do is run...
3
1236
by: JamesB | last post by:
I am trying to insert a row to an Access database: INSERT INTO tblTest (Val1, Val2, Val3, Val4, Val5) VALUES ('blah', 0, '', '', 'foo'); If I run this in my code: String insStr = "INSERT INTO INSERT INTO tblTest (Val1, Val2, Val3, Val4, Val5) VALUES ('blah', 0, '', '', 'foo'); OleDbCommand insCmd = new OleDbCommand(insStr, DBConn);
0
8653
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8597
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8457
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7127
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5554
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4150
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2587
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1763
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1460
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.