Jump to content
xisto Community
hendrikbez

Ms Acess Cannot Update Or Delete

Recommended Posts

I am using access 2003 for database, I can add, but it seems that I cannot update or delete.

I am strying to get this to work for 2 weeks now, but still not getting it to work.

Database name = Blokkies
Table name = TBlokkies
Colums leidraad (PK), A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12
Colum Leidraad has the Primary key

All of them is text.

Here is my code.

Imports System.DataImports System.Data.OleDb</P> <P>Public Class frm_Blokkies</P> <P>	Inherits System.Windows.Forms.Form</P> <P>#Region "Dim"</P> <P>	Dim SaveOrEdit As String = ""	Dim ConnString As String = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = C:\Blokkies\blokkies.mdb"</P> <P>#End Region</P> <P>#Region "Function Fill List Box"	Public Function FillListBox(ByVal Sqlstring As String)</P> <P>[tab][/tab]	ListBox1.Items.Clear()[tab][/tab]	ListView1.Items.Clear()</P> <P>[tab][/tab]	Dim OleDbConn As OleDbConnection = New OleDbConnection(ConnString)[tab][/tab]	OleDbConn.Open()[tab][/tab]	Dim MyDataReader As OleDbDataReader[tab][/tab]	Dim MyOleDbCommand As OleDbCommand = New OleDbCommand()</P> <P>[tab][/tab]	Dim MyDataSet As DataSet = New DataSet()</P> <P>[tab][/tab]	Dim MyOleDataAdapter As OleDbDataAdapter = New OleDbDataAdapter()</P> <P>[tab][/tab]	MyOleDataAdapter.SelectCommand = New OleDbCommand(Sqlstring, OleDbConn)</P> <P>[tab][/tab]	MyOleDataAdapter.Fill(MyDataSet)</P> <P>[tab][/tab]	MyOleDbCommand.Connection = (OleDbConn)</P> <P>[tab][/tab]	MyOleDbCommand.CommandText = Sqlstring</P> <P>[tab][/tab]	MyDataReader = MyOleDbCommand.ExecuteReader</P> <P>[tab][/tab]	NeroBar1.MinValue = 0[tab][/tab]	NeroBar1.MaxValue = MyDataSet.Tables(0).Rows.Count</P> <P>[tab][/tab]	Do While MyDataReader.Read</P> <P>[tab][/tab][tab][/tab]	ListBox1.Items.Add(MyDataReader("Leidraad"))</P> <P>[tab][/tab][tab][/tab]	Dim MyItem = ListView1.Items.Add(MyDataReader("Leidraad".ToString))</P> <P>[tab][/tab][tab][/tab]	With MyItem</P> <P>[tab][/tab][tab][/tab][tab][/tab]	.SubItems.Add(MyDataReader("A1").ToString)[tab][/tab][tab][/tab][tab][/tab]	.SubItems.Add(MyDataReader("A2").ToString)[tab][/tab][tab][/tab][tab][/tab]	.SubItems.Add(MyDataReader("A3").ToString)[tab][/tab][tab][/tab][tab][/tab]	.SubItems.Add(MyDataReader("A4").ToString)[tab][/tab][tab][/tab][tab][/tab]	.SubItems.Add(MyDataReader("A5").ToString)[tab][/tab][tab][/tab][tab][/tab]	.SubItems.Add(MyDataReader("A6").ToString)[tab][/tab][tab][/tab][tab][/tab]	.SubItems.Add(MyDataReader("A7").ToString)[tab][/tab][tab][/tab][tab][/tab]	.SubItems.Add(MyDataReader("A8").ToString)[tab][/tab][tab][/tab][tab][/tab]	.SubItems.Add(MyDataReader("A9").ToString)[tab][/tab][tab][/tab][tab][/tab]	.SubItems.Add(MyDataReader("A10").ToString)[tab][/tab][tab][/tab][tab][/tab]	.SubItems.Add(MyDataReader("A11").ToString)[tab][/tab][tab][/tab][tab][/tab]	.SubItems.Add(MyDataReader("A12").ToString)</P> <P>[tab][/tab][tab][/tab]	End With</P> <P>[tab][/tab]	Loop</P> <P>[tab][/tab]	MyDataReader.Close()</P> <P>[tab][/tab]	OleDbConn.Close()[tab][/tab]	OleDbConn.Dispose()</P> <P>	End Function</P> <P>#End Region</P> <P>#Region "Function Fill Text Box"</P> <P>	Public Function FillTextBox(ByVal Sqlstring As String)</P> <P>[tab][/tab]	Dim OleDbConn As OleDbConnection = New OleDbConnection(ConnString)[tab][/tab]	OleDbConn.Open()</P> <P>[tab][/tab]	Dim MyDataReader As OleDbDataReader</P> <P>[tab][/tab]	Dim MyOleDbCommand As OleDbCommand = New OleDbCommand()[tab][/tab]	MyOleDbCommand.Connection = (OleDbConn)[tab][/tab]	MyOleDbCommand.CommandText = Sqlstring</P> <P>[tab][/tab]	MyDataReader = MyOleDbCommand.ExecuteReader</P> <P>[tab][/tab]	Try[tab][/tab][tab][/tab]	Do While MyDataReader.Read</P> <P>[tab][/tab][tab][/tab][tab][/tab]	TxtLuidraad.Text = (MyDataReader.Item(0))[tab][/tab][tab][/tab][tab][/tab]	txtA1.Text = (MyDataReader.Item(1))[tab][/tab][tab][/tab][tab][/tab]	txtA2.Text = (MyDataReader.Item(2))[tab][/tab][tab][/tab][tab][/tab]	txtA3.Text = (MyDataReader.Item(3))[tab][/tab][tab][/tab][tab][/tab]	txtA4.Text = (MyDataReader.Item(4))[tab][/tab][tab][/tab][tab][/tab]	txtA5.Text = (MyDataReader.Item(5))[tab][/tab][tab][/tab][tab][/tab]	txtA6.Text = (MyDataReader.Item(6))[tab][/tab][tab][/tab][tab][/tab]	txtA7.Text = (MyDataReader.Item(7))[tab][/tab][tab][/tab][tab][/tab]	txtA8.Text = (MyDataReader.Item(8))[tab][/tab][tab][/tab][tab][/tab]	txtA9.Text = (MyDataReader.Item(9))[tab][/tab][tab][/tab][tab][/tab]	txtA10.Text = (MyDataReader.Item(10))[tab][/tab][tab][/tab][tab][/tab]	txtA11.Text = (MyDataReader.Item(11))[tab][/tab][tab][/tab][tab][/tab]	txtA12.Text = (MyDataReader.Item(12))</P> <P>[tab][/tab][tab][/tab]	Loop</P> <P>[tab][/tab][tab][/tab]	StatusLabel.Text = "Record " & TxtLuidraad.Text & " selected"</P> <P>[tab][/tab]	Catch err As System.Exception</P> <P>[tab][/tab][tab][/tab]	StatusLabel.Text = " Selected Record Contains Null String"</P> <P>[tab][/tab][tab][/tab]	MyDataReader.Close()</P> <P>[tab][/tab][tab][/tab]	OleDbConn.Close()[tab][/tab][tab][/tab]	OleDbConn.Dispose()[tab][/tab]	End Try</P> <P>	End Function</P> <P>#End Region</P> <P>#Region "Function Fill Data Grid"</P> <P>	Public Function FillDataGrid(ByVal Sqlstring As String)</P> <P>[tab][/tab]	Dim OleDbConn As OleDbConnection = New OleDbConnection(ConnString)[tab][/tab]	OleDbConn.Open()</P> <P>[tab][/tab]	Dim MyDataSet As DataSet = New DataSet()</P> <P>[tab][/tab]	Dim MyOleDataAdapter As OleDbDataAdapter = New OleDbDataAdapter()[tab][/tab]	MyOleDataAdapter.SelectCommand = New OleDbCommand(Sqlstring, OleDbConn)[tab][/tab]	MyOleDataAdapter.Fill(MyDataSet)</P> <P>[tab][/tab]	Me.DataGrid1.DataSource = MyDataSet.Tables(0)</P> <P>[tab][/tab]	StatusLabel.Text = " " & MyDataSet.Tables(0).Rows.Count & " Rows."</P> <P>[tab][/tab]	MyOleDataAdapter.Dispose()[tab][/tab]	MyDataSet.Dispose()[tab][/tab]	OleDbConn.Close()[tab][/tab]	OleDbConn.Dispose()</P> <P>	End Function</P> <P>#End Region</P> <P>#Region "Function Add New"	Public Function AddNew()</P> <P>[tab][/tab]	Try</P> <P>[tab][/tab][tab][/tab]	Dim OleDbConn As OleDbConnection = New OleDbConnection(ConnString)[tab][/tab][tab][/tab]	OleDbConn.Open()</P> <P>[tab][/tab][tab][/tab]	Dim MyOledbCommand As OleDbCommand = New OleDbCommand()</P> <P>[tab][/tab][tab][/tab]	Dim String1, String2, String3, String4, String5, string6, string7, string8, string9, string10, string11, string12, string13 As String</P> <P>[tab][/tab][tab][/tab]	String1 = TxtLuidraad.Text[tab][/tab][tab][/tab]	String2 = txtA1.Text()[tab][/tab][tab][/tab]	String3 = txtA2.Text()[tab][/tab][tab][/tab]	String4 = txtA3.Text()[tab][/tab][tab][/tab]	String5 = txtA4.Text()[tab][/tab][tab][/tab]	string6 = txtA5.Text()[tab][/tab][tab][/tab]	string7 = txtA6.Text()[tab][/tab][tab][/tab]	string8 = txtA7.Text()[tab][/tab][tab][/tab]	string9 = txtA8.Text()[tab][/tab][tab][/tab]	string10 = txtA9.Text()[tab][/tab][tab][/tab]	string11 = txtA10.Text()[tab][/tab][tab][/tab]	string12 = txtA11.Text()[tab][/tab][tab][/tab]	string13 = txtA12.Text()</P> <P>[tab][/tab][tab][/tab]	MyOledbCommand.CommandText = "Insert Into Tblokkies " _[tab][/tab][tab][/tab]	& "(leidraad,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12) " _[tab][/tab][tab][/tab]	& "Values (" _[tab][/tab][tab][/tab]	& "'" & String1 & "', " _[tab][/tab][tab][/tab]	& "'" & String2 & "', " _[tab][/tab][tab][/tab]	& "'" & String3 & "', " _[tab][/tab][tab][/tab]	& "'" & String4 & "', " _[tab][/tab][tab][/tab]	& "'" & String5 & "', " _[tab][/tab][tab][/tab]	& "'" & string6 & "', " _[tab][/tab][tab][/tab]	& "'" & string7 & "', " _[tab][/tab][tab][/tab]	& "'" & string8 & "', " _[tab][/tab][tab][/tab]	& "'" & string9 & "', " _[tab][/tab][tab][/tab]	& "'" & string10 & "', " _[tab][/tab][tab][/tab]	& "'" & string11 & "', " _[tab][/tab][tab][/tab]	& "'" & string12 & "', " _[tab][/tab][tab][/tab]	& "'" & string13 & "')"</P> <P>[tab][/tab][tab][/tab]	MyOledbCommand.Connection = OleDbConn</P> <P>[tab][/tab][tab][/tab]	MyOledbCommand.ExecuteNonQuery()[tab][/tab][tab][/tab]	OleDbConn.Close()</P> <P>[tab][/tab][tab][/tab]	FillDataGrid("Select * from Tblokkies")[tab][/tab][tab][/tab]	FillListBox("Select * from Tblokkies")[tab][/tab][tab][/tab]	DisableTextboxes()</P> <P>[tab][/tab][tab][/tab]	btnupdate.Enabled = True[tab][/tab][tab][/tab]	btnDelete.Enabled = True[tab][/tab][tab][/tab]	'btnAdd.Enabled = True</P> <P>[tab][/tab][tab][/tab]	SaveOrEdit = "Cancel"</P> <P>[tab][/tab][tab][/tab]	StatusLabel.Text = " Data Added."</P> <P>[tab][/tab]	Catch err As System.Exception[tab][/tab][tab][/tab]	StatusLabel.Text = err.Message[tab][/tab]	End Try</P> <P>	End Function</P> <P>#End Region</P> <P>#Region " Function Edit"</P> <P>	Public Function Edit() As String[tab][/tab]	Try</P> <P>[tab][/tab][tab][/tab]	Dim OleDbConn As OleDbConnection = New OleDbConnection(ConnString)[tab][/tab][tab][/tab]	OleDbConn.Open()</P> <P>[tab][/tab][tab][/tab]	Dim MyOledbCommand As OleDbCommand = New OleDbCommand()</P> <P>[tab][/tab][tab][/tab]	Dim String1, String2, String3, String4, String5, string6, string7, string8, string9, string10, string11, string12, string13 As String</P> <P>[tab][/tab][tab][/tab]	String1 = TxtLuidraad.Text[tab][/tab][tab][/tab]	String2 = txtA1.Text()[tab][/tab][tab][/tab]	String3 = txtA2.Text()[tab][/tab][tab][/tab]	String4 = txtA3.Text()[tab][/tab][tab][/tab]	String5 = txtA4.Text()[tab][/tab][tab][/tab]	string6 = txtA5.Text()[tab][/tab][tab][/tab]	string7 = txtA6.Text()[tab][/tab][tab][/tab]	string8 = txtA7.Text()[tab][/tab][tab][/tab]	string9 = txtA8.Text()[tab][/tab][tab][/tab]	string10 = txtA9.Text()[tab][/tab][tab][/tab]	string11 = txtA10.Text()[tab][/tab][tab][/tab]	string12 = txtA11.Text()[tab][/tab][tab][/tab]	string13 = txtA12.Text()</P> <P>[tab][/tab][tab][/tab]	MyOledbCommand.CommandText = "Update Tblokkies Set " _[tab][/tab][tab][/tab]	& "leidraad='" & String1 & "', " _[tab][/tab][tab][/tab]	& "A1='" & String2 & "', " _[tab][/tab][tab][/tab]	& "A2='" & String3 & "', " _[tab][/tab][tab][/tab]	& "A3='" & String4 & "', " _[tab][/tab][tab][/tab]	& "A4='" & String5 & "' " _[tab][/tab][tab][/tab]	& "A5='" & string6 & "' " _[tab][/tab][tab][/tab]	& "A6='" & string7 & "' " _[tab][/tab][tab][/tab]	& "A7='" & string8 & "' " _[tab][/tab][tab][/tab]	& "A8='" & string9 & "' " _[tab][/tab][tab][/tab]	& "A9='" & string10 & "' " _[tab][/tab][tab][/tab]	& "A10='" & string11 & "' " _[tab][/tab][tab][/tab]	& "A11='" & string12 & "' " _[tab][/tab][tab][/tab]	& "A12='" & string13 & "' " _[tab][/tab][tab][/tab]	& "WHERE leidraad = " & ListBox1.Items(ListBox1.SelectedIndex)</P> <P>[tab][/tab][tab][/tab]	MyOledbCommand.Connection = OleDbConn</P> <P>[tab][/tab][tab][/tab]	MyOledbCommand.ExecuteNonQuery()[tab][/tab][tab][/tab]	OleDbConn.Close()</P> <P>[tab][/tab][tab][/tab]	DisableTextboxes()[tab][/tab][tab][/tab]	NeroBar1.Value = 0</P> <P>[tab][/tab][tab][/tab]	FillDataGrid("Select * from Tblokkies")[tab][/tab][tab][/tab]	FillListBox("Select * from Tblokkies")</P> <P>[tab][/tab][tab][/tab]	btnaddNew.Enabled = True[tab][/tab][tab][/tab]	btnDelete.Enabled = True[tab][/tab][tab][/tab]	' btnupdate.Enabled = True</P> <P>[tab][/tab][tab][/tab]	SaveOrEdit = "Cancel"</P> <P>[tab][/tab][tab][/tab]	StatusLabel.Text = " Data Edited."[tab][/tab]	Catch err As System.Exception[tab][/tab][tab][/tab]	StatusLabel.Text = err.Message[tab][/tab]	End Try</P> <P>	End Function</P> <P>#End Region</P> <P>#Region "Function Delete"</P> <P>	Public Function Delete() As String[tab][/tab]	Try</P> <P>[tab][/tab][tab][/tab]	Dim OleDbConn As OleDbConnection = New OleDbConnection(ConnString)[tab][/tab][tab][/tab]	OleDbConn.Open()</P> <P>[tab][/tab][tab][/tab]	Dim MyOledbCommand As OleDbCommand = New OleDbCommand()</P> <P>[tab][/tab][tab][/tab]	'MyOledbCommand.CommandText = "Delete * From Tblokkies "  & "WHERE leidraad = " & ListBox1.Items(ListBox1.SelectedIndex)</P> <P>[tab][/tab][tab][/tab]	MyOledbCommand.CommandText = "DELETE * FROM [tblokkies] WHERE (leidraad= ?)'" & ListBox1.Items(ListBox1.SelectedIndex) & "'"</P> <P>[tab][/tab][tab][/tab]	MyOledbCommand.Connection = OleDbConn</P> <P>[tab][/tab][tab][/tab]	MyOledbCommand.ExecuteNonQuery()[tab][/tab][tab][/tab]	OleDbConn.Close()</P> <P>[tab][/tab][tab][/tab]	DisableTextboxes()[tab][/tab][tab][/tab]	NeroBar1.Value = 0</P> <P>[tab][/tab][tab][/tab]	FillDataGrid("Select * from Tblokkies")[tab][/tab][tab][/tab]	FillListBox("Select * from Tblokkies")[tab][/tab][tab][/tab]	StatusLabel.Text = " Data Deleted."</P> <P>[tab][/tab]	Catch err As System.Exception[tab][/tab][tab][/tab]	StatusLabel.Text = err.Message[tab][/tab]	End Try</P> <P>	End Function</P> <P>#End Region</P> <P>#Region "Delete All"</P> <P>	Public Function DeleteAll() As String[tab][/tab]	Try</P> <P>[tab][/tab][tab][/tab]	Dim OleDbConn As OleDbConnection = New OleDbConnection(ConnString)[tab][/tab][tab][/tab]	OleDbConn.Open()</P> <P>[tab][/tab][tab][/tab]	Dim MyOledbCommand As OleDbCommand = New OleDbCommand()</P> <P>[tab][/tab][tab][/tab]	MyOledbCommand.CommandText = "Delete * From Tblokkies"</P> <P>[tab][/tab][tab][/tab]	MyOledbCommand.Connection = OleDbConn</P> <P>[tab][/tab][tab][/tab]	MyOledbCommand.ExecuteNonQuery()[tab][/tab][tab][/tab]	OleDbConn.Close()</P> <P>[tab][/tab][tab][/tab]	DisableTextboxes()[tab][/tab][tab][/tab]	NeroBar1.Value = 0</P> <P>[tab][/tab][tab][/tab]	FillDataGrid("Select * from Tblokkies")[tab][/tab][tab][/tab]	FillListBox("Select * from Tblokkies")[tab][/tab][tab][/tab]	StatusLabel.Text = " Data Deleted."</P> <P>[tab][/tab]	Catch err As System.Exception[tab][/tab][tab][/tab]	StatusLabel.Text = err.Message[tab][/tab]	End Try</P> <P>	End Function</P> <P>#End Region</P> <P>#Region "Function Enable Text Boxes"</P> <P>	Public Function EnableTextboxes(ByVal ClearTextBoxes As Boolean)</P> <P>[tab][/tab]	TxtLuidraad.ReadOnly = False[tab][/tab]	txtA1.ReadOnly = False[tab][/tab]	txtA2.ReadOnly = False[tab][/tab]	txtA3.ReadOnly = False[tab][/tab]	txtA4.ReadOnly = False[tab][/tab]	txtA5.ReadOnly = False[tab][/tab]	txtA6.ReadOnly = False[tab][/tab]	txtA7.ReadOnly = False[tab][/tab]	txtA8.ReadOnly = False[tab][/tab]	txtA9.ReadOnly = False[tab][/tab]	txtA10.ReadOnly = False[tab][/tab]	txtA11.ReadOnly = False[tab][/tab]	txtA12.ReadOnly = False</P> <P>[tab][/tab]	If ClearTextBoxes = True Then[tab][/tab][tab][/tab]	TxtLuidraad.Text = vbNullString[tab][/tab][tab][/tab]	txtA1.Text = vbNullString[tab][/tab][tab][/tab]	txtA2.Text = vbNullString[tab][/tab][tab][/tab]	txtA3.Text = vbNullString[tab][/tab][tab][/tab]	txtA4.Text = vbNullString[tab][/tab][tab][/tab]	txtA5.Text = vbNullString[tab][/tab][tab][/tab]	txtA6.Text = vbNullString[tab][/tab][tab][/tab]	txtA7.Text = vbNullString[tab][/tab][tab][/tab]	txtA8.Text = vbNullString[tab][/tab][tab][/tab]	txtA9.Text = vbNullString[tab][/tab][tab][/tab]	txtA10.Text = vbNullString[tab][/tab][tab][/tab]	txtA11.Text = vbNullString[tab][/tab][tab][/tab]	txtA12.Text = vbNullString</P> <P>[tab][/tab]	End If</P> <P>	End Function</P> <P>#End Region</P> <P>#Region "Function Disable Text Boxes"</P> <P>	Public Function DisableTextboxes()</P> <P>[tab][/tab]	TxtLuidraad.ReadOnly = True[tab][/tab]	txtA1.ReadOnly = True[tab][/tab]	txtA2.ReadOnly = True[tab][/tab]	txtA3.ReadOnly = True[tab][/tab]	txtA4.ReadOnly = True[tab][/tab]	txtA5.ReadOnly = True[tab][/tab]	txtA6.ReadOnly = True[tab][/tab]	txtA7.ReadOnly = True[tab][/tab]	txtA8.ReadOnly = True[tab][/tab]	txtA9.ReadOnly = True[tab][/tab]	txtA10.ReadOnly = True[tab][/tab]	txtA11.ReadOnly = True[tab][/tab]	txtA12.ReadOnly = True</P> <P>[tab][/tab]	TxtLuidraad.Text = vbNullString[tab][/tab]	txtA1.Text = vbNullString[tab][/tab]	txtA2.Text = vbNullString[tab][/tab]	txtA3.Text = vbNullString[tab][/tab]	txtA4.Text = vbNullString[tab][/tab]	txtA5.Text = vbNullString[tab][/tab]	txtA6.Text = vbNullString[tab][/tab]	txtA7.Text = vbNullString[tab][/tab]	txtA8.Text = vbNullString[tab][/tab]	txtA9.Text = vbNullString[tab][/tab]	txtA10.Text = vbNullString[tab][/tab]	txtA11.Text = vbNullString[tab][/tab]	txtA12.Text = vbNullString</P> <P>	End Function</P> <P>#End Region</P> <P>#Region "Listbox Selected"</P> <P>	Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged</P> <P>[tab][/tab]	Dim SqlStr As String</P> <P>[tab][/tab]	SqlStr = "Select * from tblokkies where leidraad = """ & ListBox1.Items(ListBox1.SelectedIndex) & """"</P> <P>[tab][/tab]	FillTextBox(SqlStr)	End Sub</P> <P>#End Region</P> <P>#Region "Form load"</P> <P>	Private Sub frm_Blokkies_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load</P> <P>[tab][/tab]	DisableTextboxes()[tab][/tab]	FillListBox("Select * from Tblokkies")[tab][/tab]	FillDataGrid("Select * from Tblokkies")</P> <P>[tab][/tab]	Me.ClientSize = New System.Drawing.Size(823, 621)</P> <P>	End Sub</P> <P>#End Region</P> <P>#Region "Clean"</P> <P>	Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click</P> <P>[tab][/tab]	DisableTextboxes()[tab][/tab]	NeroBar1.Value = 0[tab][/tab]	FillDataGrid("select * from Tblokkies")[tab][/tab]	FillListBox("select * from Tblokkies")</P> <P>	End Sub</P> <P>#End Region</P> <P>#Region "New"</P> <P>	Private Sub btnaddNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnaddNew.Click</P> <P>[tab][/tab]	SaveOrEdit = "Save"[tab][/tab]	StatusLabel.Text = " Add new Data"[tab][/tab]	EnableTextboxes(True)</P> <P>[tab][/tab]	btnAdd.Enabled = True[tab][/tab]	btnupdate.Enabled = False[tab][/tab]	btnDelete.Enabled = False</P> <P>	End Sub</P> <P>#End Region</P> <P>#Region "Edit/Update"</P> <P>	Private Sub btnupdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnupdate.Click</P> <P>[tab][/tab]	Try</P> <P>[tab][/tab][tab][/tab]	Dim CatchError As Integer = ListBox1.Items(ListBox1.SelectedIndex)</P> <P>[tab][/tab]	Catch err As System.Exception</P> <P>[tab][/tab][tab][/tab]	StatusLabel.Text = " Select Record to Edit"[tab][/tab][tab][/tab]	Exit Sub[tab][/tab]	End Try</P> <P>[tab][/tab]	SaveOrEdit = "Edit"[tab][/tab]	StatusLabel.Text = " Edit Existing Data"</P> <P>[tab][/tab]	EnableTextboxes(False)</P> <P>[tab][/tab]	btnaddNew.Enabled = False[tab][/tab]	btnDelete.Enabled = False</P> <P>	End Sub</P> <P>#End Region</P> <P>#Region "Delete"</P> <P>	Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click</P> <P>[tab][/tab]	Try</P> <P>[tab][/tab][tab][/tab]	Dim CatchError As Integer = ListBox1.Items(ListBox1.SelectedIndex)</P> <P>[tab][/tab]	Catch err As System.Exception</P> <P>[tab][/tab][tab][/tab]	StatusLabel.Text = " Select Record to Delete"[tab][/tab][tab][/tab]	Exit Sub[tab][/tab]	End Try</P> <P>[tab][/tab]	Delete()</P> <P>	End Sub</P> <P>#End Region</P> <P>#Region "Save"</P> <P>	Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click</P> <P>[tab][/tab]	If SaveOrEdit = "Save" Then</P> <P>[tab][/tab][tab][/tab]	AddNew()</P> <P>[tab][/tab]	ElseIf SaveOrEdit = "Edit" Then</P> <P>[tab][/tab][tab][/tab]	Edit()[tab][/tab]	Else</P> <P>[tab][/tab][tab][/tab]	StatusLabel.Text = " No Data to be Saved"</P> <P>[tab][/tab]	End If</P> <P>	End Sub</P> <P>#End Region</P> <P>#Region "Cancel"</P> <P>	Private Sub btncancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncancel.Click</P> <P>[tab][/tab]	Try</P> <P>[tab][/tab][tab][/tab]	ListBox1.ClearSelected()</P> <P>[tab][/tab]	Catch err As System.Exception</P> <P>[tab][/tab]	End Try</P> <P>[tab][/tab]	SaveOrEdit = "Cancel"[tab][/tab]	DisableTextboxes()[tab][/tab]	StatusLabel.Text = " Action Canceld"</P> <P>[tab][/tab]	btnaddNew.Enabled = True[tab][/tab]	btnDelete.Enabled = True[tab][/tab]	btnupdate.Enabled = True</P> <P>	End Sub</P> <P>#End Region</P> <P>#Region "Data Grid"</P> <P>	Private Sub DataGrid1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid1.Click</P> <P>[tab][/tab]	Dim SqlStr As String</P> <P>[tab][/tab]	SqlStr = "Select * from Tblokkies where leidraad = " & DataGrid1.Item(DataGrid1.CurrentRowIndex, 0)</P> <P>[tab][/tab]	FillTextBox(SqlStr)	End Sub</P> <P>#End Region</P> <P>#Region "Back to first form"</P> <P>	Private Sub btnback_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnback.Click</P> <P>[tab][/tab]	Me.Close()[tab][/tab]	' Free the resources used by this form[tab][/tab]	Me.Dispose(True)</P> <P>	End Sub</P> <P>#End Region</P> <P>#Region "Search in Listbox"	Private Sub Txtsoek_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Txtsoek.TextChanged</P> <P>[tab][/tab]	Dim item As String = Txtsoek.Text.ToString()[tab][/tab]	Dim index As Integer = ListBox1.FindString(item)[tab][/tab]	If index = -1 Then[tab][/tab][tab][/tab]	ListBox1.SelectedIndex = ListBox1.SelectedIndex[tab][/tab]	Else[tab][/tab][tab][/tab]	ListBox1.SetSelected(index, True)[tab][/tab]	End If	End Sub#End Region</P> <P>End Class

Share this post


Link to post
Share on other sites

If you are using Windows XP system, then you hard drive may be using ntfs filesystem.

Right-click a disk that hold your database and check if it is that filesystem.

 

If it is, follow these steps to see if it's help:

 

right-click the folder contains the database and choose properties.

click the permission tab.

assign modify permission to aspnet account by clicking add button on the permission tab.

A dialog box is showed. Press the find object button then click find.

Select the aspnet user account and click add

Click twice OK to close all dialog box.


You may now rerun your script to test the update function.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.