if (comboBox1.Enab led == true && textBox5.Text != "")
{
OleDbConnection con = new OleDbConnection ();
con.ConnectionS tring = @"Provider=Micr osoft.ACE.OLEDB .12.0;" + @"Data Source= c:\users\mert\" + @"documents\vis ual studio 2010\Projects\P ayrollCS\Window sFormsApplicati on7\PayrollDB.a ccdb";
con.Open();
OleDbCommand cmdole1 = new OleDbCommand("S ELECT SalaryHead_ID FROM SalaryHead WHERE SalaryHead = '" + comboBox1.Text +"' " , con);
int salaryheadid = (int)cmdole1.Ex ecuteScalar();
OleDbCommand cmdole = new OleDbCommand("I NSERT INTO [GroupContains](SalaryGroup_ID ,SalaryHead_ID) Values ('"+textBox5.Te xt +"' , '"+ salaryheadid.To String()+"') ", con);
cmdole.ExecuteN onQuery();
try
{
OleDbCommand cmdole2 = new OleDbCommand("I NSERT INTO [SalaryCardHead](SalaryHead_ID, SalaryGroupID,V alue) Values ('"+salaryheadi d.ToString()+"' ,'"+textBox5.Te xt+"', '"+ textBox4.Text+" ') ", con);
cmdole2.Execute NonQuery();
}
catch (OleDbException err)
{
MessageBox.Show (err.ToString() );
}
this is my code. I am getting this error on "cmdole2" query.
error text is:
---------------------------
---------------------------
System.Data.Ole Db.OleDbExcepti on (0x80040E14): Syntax error in INSERT INTO statement.
at System.Data.Ole Db.OleDbCommand .ExecuteCommand TextErrorHandli ng(OleDbHResult hr)
at System.Data.Ole Db.OleDbCommand .ExecuteCommand TextForSingleRe sult(tagDBPARAM S dbParams, Object& executeResult)
at System.Data.Ole Db.OleDbCommand .ExecuteCommand Text(Object& executeResult)
at System.Data.Ole Db.OleDbCommand .ExecuteCommand (CommandBehavio r behavior, Object& executeResult)
at System.Data.Ole Db.OleDbCommand .ExecuteReaderI nternal(Command Behavior behavior, String method)
at System.Data.Ole Db.OleDbCommand .ExecuteNonQuer y()
at WindowsFormsApp lication7.Salar yGroup.SalaryGr oup.toolStripBu tton8_Click(Obj ect sender, EventArgs e) in C:\Users\MERT\d ocuments\visual studio 2010\Projects\P ayrollCS\Window sFormsApplicati on7\SalaryGroup \SalaryGroup.cs :line 306
---------------------------
OK
---------------------------
1 7470
I've found the problem. Column name Value is a reserved word for Access so it gives error. Changed the coloumn name and solved.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Tim::.. |
last post by:
Can someone please tell me why I keep getting the following error from the
code below!
Error: INSERT statement conflicted with COLUMN FOREIGN KEY constraint
'FK_tblOfficePageContent_tblPageContent'. The conflict occurred in database
'CPNCMS', table 'tblPageContent', column 'pageID'. The statement has been
terminated.
I cant seem to see why I keep getting an error when I do the insert!
|
by: jinhy82 |
last post by:
Hi! I am currently creating a Registration form which contained: UserID
Password, FirstName and LastName.
These details would be inserted into Ms Access when I click submi
button. But I encounter with the problem to insert 'Password'. It work
fine if I did not insert 'Password' but if I did, it will shows that
have "syntax error: INSERT INTO..."
Did I miss something to write? Please kindly have a look on the cod
below, Thank you!
|
by: Roy Rodsson via .NET 247 |
last post by:
Hi all!
I am using a stored procedure in SQL2000 for retrieving fileinformations from a db.
the table as an uniqueidentifier for the file information.
The stored procedure has a variable called fileIds that is oftype varchar.
I am putting in a comma separated string with ids (such as:'9B176B0C-CA03-49C9-A2E7-063038E7CF20','9B176B0C-CA03-49C9-A2E7-063038E7CF22','9B176B0C-CA03-49C9-A2E7-063038E7CF23')
However, when I execute the sp via...
|
by: tw |
last post by:
Scenario:
Error:
Microsoft JET Database Engine (0x80004005)
Operation must use an updateable query.
I have xp professional with iis6.
the folder is under wwwroot with asp file and mdb file.
Is there something with permission and LDB?
|
by: rahuls |
last post by:
Hi everyone, I have a couple of questions?
1.this is part of my main function
//////////////////////////////
int main()
{
FILE *f1;
int i,j;
j=100000000;
int intData;
| |
by: ucbu |
last post by:
Hi,
I wrote an ASP page using MS access 2000 on an ISS 5.0.
I got "Microsoft JET Database Engine (0x80040E14)
Syntax error in INSERT INTO statement." at the execute line of the sql:
insert into att(aName,line1,line2,mobile,email, noidung,image, partner) values('abcd','abd','adf','adf','df','abcde ','images/personnel/',on)
When I copy & paste this query in ms access, the query work just fine. I can see the new added record.
|
by: Yesurbius |
last post by:
I am receiving the following error when attempting to run my query. In my mind - this error should not be happening - its a straight-forward query with a subquery. I am using Access 2003 with all the latest patches.
If I do not group the query (ie. remove aggregation) it will work. If I recall, it also works if my subquery does not have joins.
I want to accomplish this with pure SQL .. I could easily write a VBA function to handle...
|
by: Ed Pisa |
last post by:
Hello,
I have been working with this problem now for several days. I can delete and Update my data but I can not get it to insert a new record. I receive the syntax error insert into. I am not using any reserved words and I have not been able to find my answer googling like crazy. Any help would be greatly appreciated. below is the code that seems to give me the problem.
ElseIf NEWMODE = True Then
Dim oAdapter As...
|
by: dougancil |
last post by:
I have the following code:
Imports System.Data.SqlClient
Public Class Main
Protected WithEvents DataGridView1 As DataGridView
Dim instForm2 As New Exceptions
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles startpayrollButton.Click
Dim ssql As String = "select MAX(payrolldate) AS , " & _
"dateadd(s, 518399, max(payrolldate)) AS " & _
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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...
|
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...
|
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...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
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...
| |