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
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
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
Comment