Code:
Imports System.Data.OleDb
Imports System.Data.SqlClient
Public Class Form1
Dim ConnString As String
Dim SQLStr As String
Dim SQLConn As New SqlConnection() 'The SQL Connection
Dim SQLCmd As New SqlCommand() 'The SQL Command
Private Sub count()
Dim records, current As Integer
records = Me.BindingContext( _
DataSet11, "students").Count
current = Me.BindingContext( _
DataSet11, "students").Position + 1
Label1.Text = "record " & current.ToString & " of " & _
records.ToString
End Sub
Private Sub zoek_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles zoek.Click
DataSet11.Clear()
OleDbDataAdapter1.Fill(DataSet11)
count()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.BindingContext(DataSet11, "students").Position = 0
count()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Connstring = Server Name, Database Name, Windows Authentication
ConnString = "wat moet hier komen?;Initial Catalog=students;User ID=Admin;Password="
SQLConn.ConnectionString = ConnString 'Set the Connection String
SQLConn.Open() 'Open the connection
SQLCmd.Connection = SQLConn 'Sets the Connection to use with the SQL Command
SQLCmd.CommandText = SQLStr 'Sets the SQL String
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.BindingContext(DataSet11, "students").Position = _
Me.BindingContext(DataSet11, "students").Count - 1
count()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Me.BindingContext(DataSet11, "students").Position += 1
count()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Me.BindingContext(DataSet11, "students").Position -= 1
count()
End Sub
Private Sub StudentsBindingSource_CurrentChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StudentsBindingSource.CurrentChanged
End Sub
Private Sub OleDbDataAdapter1_RowUpdated(ByVal sender As System.Object, ByVal e As System.Data.OleDb.OleDbRowUpdatedEventArgs) Handles OleDbDataAdapter1.RowUpdated
End Sub
Private Sub OleDbConnection1_InfoMessage(ByVal sender As System.Object, ByVal e As System.Data.OleDb.OleDbInfoMessageEventArgs) Handles OleDbConnection1.InfoMessage
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Dim naam, voornaam, leeftijd As String
naam = TextBox6.Text
voornaam = TextBox5.Text
leeftijd = TextBox4.Text
SQLStr = "INSERT into students(id, naam, voornaam, leeftijd, foto) VALUES('10', 'HoSQL?', 'blubber', '4','sdf' )"
SQLCmd.CommandText = SQLStr 'Sets the SQL String
SQLCmd.ExecuteNonQuery() 'Executes SQL Commands Non-Querys only
End Sub
End Class

dit stuk dus:
Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Connstring = Server Name, Database Name, Windows Authentication
ConnString = "wat moet hier komen?;Initial Catalog=students;User ID=Admin;Password="
SQLConn.ConnectionString = ConnString 'Set the Connection String
SQLConn.Open() 'Open the connection
SQLCmd.Connection = SQLConn 'Sets the Connection to use with the SQL Command
SQLCmd.CommandText = SQLStr 'Sets the SQL String
End Sub
Laatst bewerkt: