Imports [Link].
OleDb
Module Module1
Public connstr As String = "Provider=[Link].4.0; data
source =" & [Link] & "\[Link]"
Public conn As New OleDbConnection(connstr)
//this is our module on the previous lesson
Function connect()
If [Link] = [Link] Then
[Link]()
End If
Return True
End Function
End Module
This is for the form and the global variables to be used
Imports [Link]
Public Class Form1
Dim da As New OleDbDataAdapter
Dim dset As New DataSet
Dim Comm As OleDbCommand
Dim code As String
End Class
//this is the code to used for the base load of form 1.
Private Sub Form1_Load(ByVal sender As [Link], ByVal e As
[Link]) Handles [Link]
populate()
da = New OleDbDataAdapter("Select * from Studentcourse", conn)
dset = New DataSet
[Link](dset, "Studentcourse")
Dim count As Integer = [Link]("Studentcourse").[Link]
Dim x As Integer
For x = 0 To count - 1
[Link]([Link]("Studentcourse").Rows(x).Item("Cd
es"))
Next
End Sub
//In this you can select the coursecode by selecting course description
//the function populate is used in form load
Function populate()
da = New OleDbDataAdapter("Select * from Studentdata", conn)
dset = New DataSet
[Link](dset, "Studentdata")
[Link] = [Link]("Studentdata").DefaultView
Return True
End Function
//finally the command to add a record to the database
Private Sub BADD_Click(ByVal sender As [Link], ByVal e As
[Link]) Handles [Link]
code = [Link]("Studentcourse").Rows(0).Item("Ccode")
connect()
Comm = New OleDbCommand
[Link] = conn
[Link] = "Insert into Studentdata values('" &
[Link] & "', '" & [Link] & "', '" & [Link] & "', '" &
code & "', '" & [Link] & "')"
[Link]() //Executes a statement that does not
return a result set, such as an INSERT, UPDATE, DELETE, or data
definition statement.
MsgBox("Succesfully Added into Database")
populate()
End Sub