hoi, ik was een check in list aant maken voor mijn LAN organisatie, maar nu lukt me 1ding nie, schrijven-delete-update van de database wilt niet. er uit lezen gaat wel
hier is mijn code:
Imports System.Data.DataSet
Imports System.Data
Imports System.Xml
Public Class Form1
Public MaxRows
Dim inc As Integer
Dim con As New OleDb.OleDbConnection
Dim ds As New DataSet
Dim da As OleDb.OleDbDataAdapter
Dim temp As Integer
Dim sql As String
Private Sub NavigateRecords()
IDTextBox.Text = ds.Tables("list").Rows(inc).Item(0)
UsernameTextBox.Text = ds.Tables("list").Rows(inc).Item(1)
VoornaamTextBox.Text = ds.Tables("list").Rows(inc).Item(3)
AchternaamTextBox.Text = ds.Tables("list").Rows(inc).Item(4)
PostcodeTextBox.Text = ds.Tables("list").Rows(inc).Item(5)
PlaatsTextBox.Text = ds.Tables("list").Rows(inc).Item(6)
LandTextBox.Text = ds.Tables("list").Rows(inc).Item(6)
GeslachtTextBox.Text = ds.Tables("list").Rows(inc).Item(
txtgebdat.Text = ds.Tables("list").Rows(0).Item(inc)
HomepageTextBox.Text = ds.Tables("list").Rows(inc).Item(10)
Msn_adressTextBox.Text = ds.Tables("list").Rows(inc).Item(11)
EmailTextBox.Text = ds.Tables("list").Rows(inc).Item(2)
ProcessorTextBox.Text = ds.Tables("list").Rows(inc).Item(12)
Inter_geheugenTextBox.Text = ds.Tables("list").Rows(inc).Item(13)
Video_GPUTextBox.Text = ds.Tables("list").Rows(inc).Item(14)
End Sub
Private Sub btnnext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnnext.Click
If inc <> MaxRows - 1 Then
inc = inc + 1
NavigateRecords()
Else
MsgBox("No More Rows")
End If
End Sub
Private Sub btnvorig_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnvorig.Click
If inc > 0 Then
inc = inc - 1
NavigateRecords()
ElseIf inc = -1 Then
MsgBox("No Records Yet")
Else
MsgBox("First Record")
End If
End Sub
Private Sub btnlast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnlast.Click
If inc <> MaxRows - 1 Then
inc = MaxRows - 1
NavigateRecords()
End If
End Sub
Private Sub btnfirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnfirst.Click
If inc <> 0 Then
inc = 0
NavigateRecords()
End If
End Sub
Public Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'ListDataSet11.gegevens' table. You can move, or remove it, as needed.
Me.GegevensTableAdapter1.Fill(Me.ListDataSet11.gegevens)
con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = C:\Program Files\VB log in systeem\list.mdb"
con.Open()
sql = "SELECT * FROM gegevens"
Dim da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "list")
da.update(ds, "list")
con.Close()
MaxRows = ds.Tables("list").Rows.Count
inc = -1
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
End
End Sub
Private Sub btnupdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnupdate.Click
con.Open()
sql = "Update list SET list WHERE list"
Dim da = New OleDb.OleDbDataAdapter(sql, con)
Dim cb As New OleDb.OleDbCommandBuilder(da)
ds.Tables("list").Rows(inc).Item(0) = IDTextBox.Text
ds.Tables("list").Rows(inc).Item(1) = UsernameTextBox.Text
ds.Tables("list").Rows(inc).Item(3) = VoornaamTextBox.Text
ds.Tables("list").Rows(inc).Item(4) = AchternaamTextBox.Text
ds.Tables("list").Rows(inc).Item(5) = PostcodeTextBox.Text
ds.Tables("list").Rows(inc).Item(6) = PlaatsTextBox.Text
ds.Tables("list").Rows(inc).Item(6) = LandTextBox.Text
ds.Tables("list").Rows(inc).Item(
= GeslachtTextBox.Text
ds.Tables("list").Rows(0).Item(inc) = txtgebdat.Text
ds.Tables("list").Rows(inc).Item(10) = HomepageTextBox.Text
ds.Tables("list").Rows(inc).Item(11) = Msn_adressTextBox.Text
ds.Tables("list").Rows(inc).Item(2) = EmailTextBox.Text
ds.Tables("list").Rows(inc).Item(12) = ProcessorTextBox.Text
ds.Tables("list").Rows(inc).Item(13) = Inter_geheugenTextBox.Text
ds.Tables("list").Rows(inc).Item(14) = Video_GPUTextBox.Text
da.Update(ds, "list")
con.Close()
MsgBox("Succesvol geupdate")
End Sub
Private Sub btnaddnew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnaddnew.Click
If inc <> -1 Then
Dim cb As New OleDb.OleDbCommandBuilder(da)
Dim dsNewRow As DataRow
dsNewRow = ds.Tables("AddressBook").NewRow()
ds.Tables("list").Rows(inc).Item(0) = IDTextBox.Text
ds.Tables("list").Rows(inc).Item(1) = UsernameTextBox.Text
ds.Tables("list").Rows(inc).Item(3) = VoornaamTextBox.Text
ds.Tables("list").Rows(inc).Item(4) = AchternaamTextBox.Text
ds.Tables("list").Rows(inc).Item(5) = PostcodeTextBox.Text
ds.Tables("list").Rows(inc).Item(6) = PlaatsTextBox.Text
ds.Tables("list").Rows(inc).Item(6) = LandTextBox.Text
ds.Tables("list").Rows(inc).Item(
= GeslachtTextBox.Text
ds.Tables("list").Rows(0).Item(inc) = txtgebdat.Text
ds.Tables("list").Rows(inc).Item(10) = HomepageTextBox.Text
ds.Tables("list").Rows(inc).Item(11) = Msn_adressTextBox.Text
ds.Tables("list").Rows(inc).Item(2) = EmailTextBox.Text
ds.Tables("list").Rows(inc).Item(12) = ProcessorTextBox.Text
ds.Tables("list").Rows(inc).Item(13) = Inter_geheugenTextBox.Text
ds.Tables("list").Rows(inc).Item(14) = Video_GPUTextBox.Text
ds.Tables("list").Rows.Add(dsNewRow)
da.Update(ds, "list")
MsgBox("New Record added to the Database")
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If MessageBox.Show("Do you really want to Delete this Record?", _
"Delete", MessageBoxButtons.YesNo, _
MessageBoxIcon.Warning) = DialogResult.No Then
MsgBox("Operation Cancelled")
Exit Sub
Else
Dim cb As New OleDb.OleDbCommandBuilder(da)
ds.Tables("list").Rows(inc).Delete()
MaxRows = MaxRows - 1
inc = 0
NavigateRecords()
da.Update(ds, "list")
End If
End Sub
End Class
dank bij voorbaat
Cassini
hier is mijn code:
Imports System.Data.DataSet
Imports System.Data
Imports System.Xml
Public Class Form1
Public MaxRows
Dim inc As Integer
Dim con As New OleDb.OleDbConnection
Dim ds As New DataSet
Dim da As OleDb.OleDbDataAdapter
Dim temp As Integer
Dim sql As String
Private Sub NavigateRecords()
IDTextBox.Text = ds.Tables("list").Rows(inc).Item(0)
UsernameTextBox.Text = ds.Tables("list").Rows(inc).Item(1)
VoornaamTextBox.Text = ds.Tables("list").Rows(inc).Item(3)
AchternaamTextBox.Text = ds.Tables("list").Rows(inc).Item(4)
PostcodeTextBox.Text = ds.Tables("list").Rows(inc).Item(5)
PlaatsTextBox.Text = ds.Tables("list").Rows(inc).Item(6)
LandTextBox.Text = ds.Tables("list").Rows(inc).Item(6)
GeslachtTextBox.Text = ds.Tables("list").Rows(inc).Item(
txtgebdat.Text = ds.Tables("list").Rows(0).Item(inc)
HomepageTextBox.Text = ds.Tables("list").Rows(inc).Item(10)
Msn_adressTextBox.Text = ds.Tables("list").Rows(inc).Item(11)
EmailTextBox.Text = ds.Tables("list").Rows(inc).Item(2)
ProcessorTextBox.Text = ds.Tables("list").Rows(inc).Item(12)
Inter_geheugenTextBox.Text = ds.Tables("list").Rows(inc).Item(13)
Video_GPUTextBox.Text = ds.Tables("list").Rows(inc).Item(14)
End Sub
Private Sub btnnext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnnext.Click
If inc <> MaxRows - 1 Then
inc = inc + 1
NavigateRecords()
Else
MsgBox("No More Rows")
End If
End Sub
Private Sub btnvorig_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnvorig.Click
If inc > 0 Then
inc = inc - 1
NavigateRecords()
ElseIf inc = -1 Then
MsgBox("No Records Yet")
Else
MsgBox("First Record")
End If
End Sub
Private Sub btnlast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnlast.Click
If inc <> MaxRows - 1 Then
inc = MaxRows - 1
NavigateRecords()
End If
End Sub
Private Sub btnfirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnfirst.Click
If inc <> 0 Then
inc = 0
NavigateRecords()
End If
End Sub
Public Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'ListDataSet11.gegevens' table. You can move, or remove it, as needed.
Me.GegevensTableAdapter1.Fill(Me.ListDataSet11.gegevens)
con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = C:\Program Files\VB log in systeem\list.mdb"
con.Open()
sql = "SELECT * FROM gegevens"
Dim da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "list")
da.update(ds, "list")
con.Close()
MaxRows = ds.Tables("list").Rows.Count
inc = -1
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
End
End Sub
Private Sub btnupdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnupdate.Click
con.Open()
sql = "Update list SET list WHERE list"
Dim da = New OleDb.OleDbDataAdapter(sql, con)
Dim cb As New OleDb.OleDbCommandBuilder(da)
ds.Tables("list").Rows(inc).Item(0) = IDTextBox.Text
ds.Tables("list").Rows(inc).Item(1) = UsernameTextBox.Text
ds.Tables("list").Rows(inc).Item(3) = VoornaamTextBox.Text
ds.Tables("list").Rows(inc).Item(4) = AchternaamTextBox.Text
ds.Tables("list").Rows(inc).Item(5) = PostcodeTextBox.Text
ds.Tables("list").Rows(inc).Item(6) = PlaatsTextBox.Text
ds.Tables("list").Rows(inc).Item(6) = LandTextBox.Text
ds.Tables("list").Rows(inc).Item(
ds.Tables("list").Rows(0).Item(inc) = txtgebdat.Text
ds.Tables("list").Rows(inc).Item(10) = HomepageTextBox.Text
ds.Tables("list").Rows(inc).Item(11) = Msn_adressTextBox.Text
ds.Tables("list").Rows(inc).Item(2) = EmailTextBox.Text
ds.Tables("list").Rows(inc).Item(12) = ProcessorTextBox.Text
ds.Tables("list").Rows(inc).Item(13) = Inter_geheugenTextBox.Text
ds.Tables("list").Rows(inc).Item(14) = Video_GPUTextBox.Text
da.Update(ds, "list")
con.Close()
MsgBox("Succesvol geupdate")
End Sub
Private Sub btnaddnew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnaddnew.Click
If inc <> -1 Then
Dim cb As New OleDb.OleDbCommandBuilder(da)
Dim dsNewRow As DataRow
dsNewRow = ds.Tables("AddressBook").NewRow()
ds.Tables("list").Rows(inc).Item(0) = IDTextBox.Text
ds.Tables("list").Rows(inc).Item(1) = UsernameTextBox.Text
ds.Tables("list").Rows(inc).Item(3) = VoornaamTextBox.Text
ds.Tables("list").Rows(inc).Item(4) = AchternaamTextBox.Text
ds.Tables("list").Rows(inc).Item(5) = PostcodeTextBox.Text
ds.Tables("list").Rows(inc).Item(6) = PlaatsTextBox.Text
ds.Tables("list").Rows(inc).Item(6) = LandTextBox.Text
ds.Tables("list").Rows(inc).Item(
ds.Tables("list").Rows(0).Item(inc) = txtgebdat.Text
ds.Tables("list").Rows(inc).Item(10) = HomepageTextBox.Text
ds.Tables("list").Rows(inc).Item(11) = Msn_adressTextBox.Text
ds.Tables("list").Rows(inc).Item(2) = EmailTextBox.Text
ds.Tables("list").Rows(inc).Item(12) = ProcessorTextBox.Text
ds.Tables("list").Rows(inc).Item(13) = Inter_geheugenTextBox.Text
ds.Tables("list").Rows(inc).Item(14) = Video_GPUTextBox.Text
ds.Tables("list").Rows.Add(dsNewRow)
da.Update(ds, "list")
MsgBox("New Record added to the Database")
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If MessageBox.Show("Do you really want to Delete this Record?", _
"Delete", MessageBoxButtons.YesNo, _
MessageBoxIcon.Warning) = DialogResult.No Then
MsgBox("Operation Cancelled")
Exit Sub
Else
Dim cb As New OleDb.OleDbCommandBuilder(da)
ds.Tables("list").Rows(inc).Delete()
MaxRows = MaxRows - 1
inc = 0
NavigateRecords()
da.Update(ds, "list")
End If
End Sub
End Class
dank bij voorbaat
Cassini