|
-
Aug 12th, 2018, 04:30 PM
#1
Thread Starter
New Member
Vb.net _ Ms-AccessDb /insert into Query errors / exception : 'incorrect file name'.
can someone please help me with this ? 
im using VB.net2017 / Ms-AccessDb 2010
this code below is a simple version that i made , of my main app that im working on , because my main code has 48 radio buttons( 24 equipments status to check if they on or fail ) and 15 textbox , and i did put them in same Db table as columns that the insert query looks so long in vb , cuz i didnt know any other method ,
the thing is , i keep getting the errors in these lines below :
connection.open() [error said cant find the file , but my file path is not wrong]
mycommand.CommandText = "INSERT INTO Status (.... ect )
mycommand.ExecuteNonQuery() [ error : exception .... ]
da.Fill(ds, "[Status]") [also error in the select query coudnt find the table or incorrect file name ]



HERE's The Form1.vb Code :
Code:
Imports System.Data.OleDb
Public Class Form1
Dim s1 As Boolean
Dim s2 As Boolean
Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Label_currentdate.Text = DateTime.Now.ToString()
End Sub
Private Sub BTN_Save_Click(sender As Object, e As EventArgs) Handles BTN_Save.Click
Dim myconnexion As OleDbConnection = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data source=C:\Users\acer\Desktop\ABC.accdb")
Dim mycommand As OleDbCommand = myconnexion.CreateCommand()
myconnexion.Open()
mycommand.CommandText = "INSERT INTO Status (item-Number,CurrentDate,Employee_Name,Equip2 status,Equip1 status)
VALUES('" & Label_items.Text & "','" & Label_currentdate.Text & "','" & TextBox_EmployeeName.Text & "','" & s1 & "','" & s2 & "')"
mycommand.ExecuteNonQuery()
MsgBox(" successfully saved !")
myconnexion.Close()
End Sub
Private Sub RB1_CheckedChanged(sender As Object, e As EventArgs) Handles RB1.CheckedChanged
s1 = True
End Sub
Private Sub RB2_CheckedChanged(sender As Object, e As EventArgs) Handles RB2.CheckedChanged
s1 = False
End Sub
Private Sub RB3_CheckedChanged(sender As Object, e As EventArgs) Handles RB3.CheckedChanged
s2 = True
End Sub
Private Sub RB4_CheckedChanged(sender As Object, e As EventArgs) Handles RB4.CheckedChanged
s2 = False
End Sub
Private Sub BTN_reset_Click(sender As Object, e As EventArgs) Handles BTN_reset.Click
Dim RB As RadioButton
TextBox_EmployeeName.Text = ""
For Each RB In GBX1.Controls
RB.Checked = False
Next
For Each RB In GBX2.Controls
RB.Checked = False
Next
End Sub
Private Sub Label_currentdate_Click(sender As Object, e As EventArgs)
End Sub
Private Sub BTN_History_Click(sender As Object, e As EventArgs) Handles BTN_History.Click
Dim conn As New OleDbConnection
Dim cmd As New OleDbCommand
Dim da As OleDbDataAdapter
Dim ds As DataSet
Dim table As DataTableCollection
Dim source1 As New BindingSource
'
'
conn = New OleDbConnection With {.ConnectionString = "provider=Microsoft.ACE.OLEDB.12.0;Data source=C:\Users\acer\Desktop\ABC.accdb"}
ds = New DataSet
table = ds.Tables
da = New OleDbDataAdapter("Select * from [Status]", conn)
da.Fill(ds, "[Status]")
Dim view As New DataView(table(0))
source1.DataSource = view
DataGridView.DataSource = view
End Sub [/COLOR]
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Label_items.Text = "item number 1 "
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Label_items.Text = "item number 2"
End Sub
End Class
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|