Anyone can help me with this please ?
The app you see rn is nothing like the app im working on , i made it way simple.
** because of the versions ?? I'm 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 too many radio buttons( equipments status to check if they on or fail ) and more than 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 , and i dont want create the gridviewcolumns myself because i got over 50 columns that would be long , i just need to use simple code as possible .
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 ]
pic1(click me): example of error i keep getting
pic2 : the simple form1 with it code below .
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
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