hello guys
I am new here and in programing
I have this program that I am designing am using Visual studio 2010 and ms access 2010. am using ms access as a data base i have successfully designed the form and runs it but when ever I try to save to my data base it shows me "syntax error insert into statement" and I have checked all I know. mind you I use text box all through
thanks in anticipation
here is my code -
Imports System
-
Imports System.Collections.Generic
-
Imports System.ComponentModel
-
Imports System.Data
-
Imports System.Data.SqlClient
-
Imports System.Drawing
-
Imports System.Text
-
Imports System.Windows.Forms
-
Imports System.Data.OleDb
-
Imports System.Data.OleDb.OleDbConnection
-
Public Class Form1
-
Dim dbSave As New OleDb.OleDbCommand
-
Dim dbConnect As New OleDb.OleDbConnection
-
Dim sReader As OleDb.OleDbDataReader
-
Dim Line As String = Environment.NewLine
-
Private Sub Label7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label7.Click
-
-
End Sub
-
-
Private Sub TextBox4_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtpayslipno.TextChanged
-
-
End Sub
-
-
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
-
Try
-
dbConnect.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Admin\Desktop\pastor work\WindowsApplication6\Database9.accdb"
-
dbconnect.Open()
-
Catch ex As Exception
-
MessageBox.Show(ex.Message + Line + "Main Database Not Found" + Line + "Check form_AccessMaintenance source code" + Line + "Database Path", "Critical Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
-
Me.Close()
-
End Try
-
End Sub
-
-
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
-
Dim xempi, xempn, xdept, xpsn, xbspm, xpp, xsp, xpd, xovtc, xshc, xtall, xtxp, xtam, xtram, xmisp, xld, xla, xpfi, xesi, xtax, xmec, xcoc, xlcam, xmisd, xremk As String
-
xempi = txtemployid.Text
-
xempn = txtemployname.Text
-
xdept = txtdepartment.Text
-
xpsn = txtpayslipno.Text
-
xbspm = txtBasicsalary.Text
-
xpp = txtpayperiod.Text
-
xsp = txtSalaryperiod.Text
-
xpd = txtpaiddate.Text
-
xovtc = txtOvertimec.Text
-
xshc = txtshiftcharge.Text
-
xtall = txttotalal.Text
-
xtxp = txttotalexp.Text
-
xtam = txttotalam.Text
-
xtram = txttrainingam.Text
-
xmisp = txtmiscpay.Text
-
xld = txtleaveday.Text
-
xla = txtleaveam.Text
-
xpfi = txtpfi.Text
-
xesi = txtesi.Text
-
xtax = txttaxam.Text
-
xmec = txtmesscha.Text
-
xcoc = txtconveyancec.Text
-
xlcam = txtlcelamount.Text
-
xmisd = txtmiscdeduction.Text
-
xremk = txtremark.Text
-
-
-
If txtemployid.Text = "" Then
-
-
End If
-
-
Try
-
-
xempi = txtemployid.Text
-
xempn = txtemployname.Text
-
dbSave.CommandText = "INSERT INTO Table1(EmployeeID, EmployeeName, Department, PayslipNo,Basicsalaryperm, Payperiod, SalaryPeriod, PAidDays, Overtimecharge, ShiftCharge, TotalAllawance, TotalExpenses, TotalAmount, TrainingAmount, MiscPAyment, LeaveAmount, PFI, ESI, TaxAmount, MessAmount, COnveyanceCharge, LC/ELAmount, MiscDeduction, Remarks) VALUES ('" & xempi & "','" & xempn & "','" & xdept & "','" & xpsn & "','" & xbspm & "','" & xpp & "','" & xsp & "','" & xpd & "','" & xovtc & "','" & xshc & "','" & xtall & "','" & xtxp & "','" & xtam & "','" & xtram & "','" & xmisp & "','" & xld & "','" & xla & "','" & xpfi & "','" & xesi & "','" & xtax & "','" & xmec & "','" & xcoc & "','" & xlcam & "','" & xmisd & "','" & xremk & "')"
-
'MsgBox(dbInsert.CommandText)
-
dbSave.CommandType = CommandType.Text
-
dbSave.Connection = dbConnect
-
dbSave.ExecuteNonQuery()
-
MessageBox.Show("Record Posted Succesfully for " + Line + txtemployid.Text)
-
Catch ex As Exception
-
MessageBox.Show(ex.Message)
-
End Try
-
-
End Sub
-
-
'Private Function dbSave() As Object
-
' Throw New NotImplementedException
-
'End Function
-
-
End Class
1 1630
You specified 24 fields yet you are trying to insert 25 fields.
Also your LC/ELAmount has a non-standard field character so you will need to tell SQL that it's a field name by surrounding it in square brackets.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: kosta |
last post by:
hello! one of my forms communicates with a database, and is
supposed to add a row to a table using an Insert
statement... however, I get a 'oledb - syntax error'
exception... I have double...
|
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...
|
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...
|
by: Nathan Sokalski |
last post by:
When trying to submit data to an Access database using ASP.NET I recieve the
following error:
System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32 hr)
+41...
|
by: amitbadgi |
last post by:
Hi guys, I am getting the following error in teh insert statement , I
am converting this asp application to asp.net, here is teh error,
Exception Details:...
|
by: Geoffrey KRETZ |
last post by:
Hello,
I'm wondering if the following behaviour is the correct one for
PostGreSQL (7.4 on UNIX).
I've a table temp_tab with 5 fields (f1,f2,f3,...),and I'm a launching
the following request :...
|
by: vasanth chandrasekaran |
last post by:
The error is :Syntax error in INSERT INTO statement.
This is my code:
try
{
DataSet ds1;
OleDbConnection ConnSql;
OleDbConnection...
|
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...
|
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...
|
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
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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...
|
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,...
|
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...
|
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...
|
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...
| |