There are 2 part in below coding 1. Module code for binding data base 2. Form coding for binding tables
1. Module code
Imports System.Data.Odbc Module Module1 Public cn As OdbcConnection Public da As OdbcDataAdapter Public ds As New DataSet
Dim activeprocess As String Public Sub CreateConnection() Try
'cn = New OdbcConnection("Provider=Microsoft.Jet.OLEDB.4.0;DataSource= E:\projects\hospital mgt\HOSPITAL_ MGT.mdb")
Comment :- By DNS> cn = New OdbcConnection("Dsn=Hospital") Catch ex As Exception MessageBox.Show(ex.Message) End Try
End Sub
2. Table Binding Code In form Load
Imports System.Data Imports System.Data.Odbc Public Class frmNewPatientEntry Dim databinding1, databinding2 As New BindingSource Dim drow As DataRow Dim FindRow As Object Dim Odbcinput, ssql, odbcinput1 As String Dim saction, i As Integer Dim objDataView As New DataView Private Sub NewPatientEntry_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load CreateConnection() ' Call RefreshData Procedure Call refreshdata() ' Call BindFields Procedure Call BindFields() 'Call BindFields1() End Sub Private Sub refreshdata() 'FOR PATIENT TABLE Try cn.Close() If cn.State = ConnectionState.Closed Then cn.Open() da = New OdbcDataAdapter("select * from Pati_info", cn) ds = New DataSet da.Fill(ds, "Pati_info") da.Dispose()
databinding1.DataSource = ds.Tables("Pati_info") ' Binding TBLTRIAL table to data databinding1.Sort = "Patient_ID" 'To sort and Search Record ID wise Catch ex As Exception MessageBox.Show(ex.Message) End Try ' FOR RECEIPT TABLE Try da1 = New OdbcDataAdapter("select * from Receipt", cn) ds1 = New DataSet da1.Fill(ds1, "Receipt") da1.Dispose()
databinding2.DataSource = ds1.Tables("Receipt") ' Binding TBLTRIAL table to data databinding2.Sort = "Receipt_No" 'To sort and Search Record ID wise
cn.Close() ' Call fillcombo() Catch ex As Exception MessageBox.Show(ex.Message) End Try End Sub Private Sub BindFields() Try 'FOR PATIENT TABLE FindRow = CType(databinding1.Current, Object) txtID.Text = FindRow("Patient_ID") txtNM.Text = FindRow("Patient_Nm") CBType.Text = FindRow("Patient_Type") If CBType.Text = "Accident" Then txtAccNo.Text = FindRow("Accident_No") txtAccdt.Text = FindRow("Accident_D_T") txtFIRdt.Text = FindRow("FIR_D_T") txtFIRNo.Text = FindRow("FIR_No") txtAccType.Text = FindRow("Accident_Type") Else txtAccNo.Text = "" txtAccdt.Text = "" txtFIRdt.Text = "" txtFIRNo.Text = "" txtAccType.Text = "" End If txtAdd.Text = FindRow("Patient_Add") txtPh.Text = FindRow("Patient_Ph") txtMo.Text = FindRow("Patient_Mob") txtAge.Text = FindRow("Patient_Age") cmbGender.Text = FindRow("Patient_Sex") txtDOB.Text = FindRow("Patient_DOB") DateTimePicker1.Text = FindRow("Adm_D_T") txtRelation.Text = FindRow("Relation") txtRespNM.Text = FindRow("Patient_Resp_Per_Nm")
' FOR RECEIPT TABLE FindRow = CType(databinding2.Current, Object) txtAdvPay.Text = FindRow("Adv_Pay")
Catch ex As Exception MessageBox.Show(ex.Message) End Try End Sub
By these 2 code Undestand the logic of Data base & Table Binding logic.
|
No responses found. Be the first to respond and make money from revenue sharing program.
|