DB Prog Print
DB Prog Print
DB Prog Print
form1
Public Class Form1
Dim cn As New Data.OleDb.OleDbConnection
Private 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 'SampledbDataSet2.Stud'
table. You can move, or remove it, as needed.
Me.StudTableAdapter.Fill(Me.SampledbDataSet2.Stud)
cn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=D:\sampledbprog\sampledbprog\sampledb.accdb"
'cn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=D:\sampledbprog\sampledbprog\Sampledb.mdf"
cn.Open()
End Sub
End Sub
End Sub
form2
Imports System.Data.SqlClient
Public Class Form2
Dim cn As New SqlConnection
Dim cmd As New SqlCommand
Dim rs As SqlDataReader
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
cn = New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=D:\
sampledbprog\sampledbprog\Sampledb.mdf;Integrated Security=True;Connect
Timeout=30;User Instance=True")
cn.Open()
End Sub
Function clearForm()
txtregno.Text = ""
txtname.Text = ""
txtfind.Text = ""
txtcourse.Text = ""
Return 0
End Function
End Sub
End Sub
End Sub
End Class
form3
Imports System.Data.SqlClient
Public Class Form3
Dim cn As System.Data.SqlClient.SqlConnection
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
cn = New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=D:\
sampledbprog\sampledbprog\Sampledb.mdf;Integrated Security=True;Connect
Timeout=30;User Instance=True")
cn.Open()
End Sub
Private Sub butfind_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles butfind.Click
If Len(Trim(txtfind.Text)) = 0 Then
MsgBox("Please Enter RegNO to Find", MsgBoxStyle.OkOnly)
Else
Dim cmd As New System.Data.SqlClient.SqlCommand("select * from
Stud where SRegno='" & txtfind.Text & "'", cn)
Dim dr As System.Data.SqlClient.SqlDataReader
dr = cmd.ExecuteReader()
If dr.Read() Then
txtregno.Text = dr(0).ToString()
txtname.Text = dr(1).ToString()
txtcourse.Text = dr(2).ToString()
Else
MsgBox("NOT Exist...!", MsgBoxStyle.Exclamation)
txtregno.Text = ""
txtname.Text = ""
txtcourse.Text = ""
txtfind.Text = ""
End If
dr.Close()
End If
End Sub
End Sub
End If
End Sub
Private Function ChekRegNo(ByVal regno As String) As Boolean
Dim a As Boolean
a = False
Dim cmd2 As New System.Data.SqlClient.SqlCommand("select * from Stud
where SRegno='" & regno & "'", cn)
Dim dr As System.Data.SqlClient.SqlDataReader
dr = cmd2.ExecuteReader()
If dr.Read() Then
a = True
End If
dr.Close()
ChekRegNo = a
End Function
End Class