Hey everyone!

Im hoping to find someone that can help me with a problem that I cant seem to resolve and it's driving me crazy!

Basically I am trying to create a child management system for a nurse using vb.net and SQL as my backend db
The application consists of a number of differen forms. Two of these forms are called "frmSearchInfo" and "frmChildDetails".

frmSearchInfo consists of:
- three textboxes "SFirstName" "SLastName" and "SDOB"
- one button "BtnSend"

frmChildDetails consists of:
-eight textboxes ID, first name, second name, DOB, phone, addressline1, addressline2, county,
-DataGrid

The application is connected to a SQL database with two tables "Parent_Details" and "Child"

When users enter details on form "frmSearchInfo" I want it to be able to search records in the database and return the same first name, second name and DOB as well as the ID, phone, addressline1, addressline2, county. I also want the datagrid to show dates of appointments for the children.
The records needed are stored in the Child Table.

Is this possible to do or is there an easier way of going about it??

Hope that's not too confusing!
Thanks in advance!

Recommended Answers

All 3 Replies

Show us your code work please. Please use BB code tags while posting source program.

[code]

.... [/code]

Take a look at forum rules.

prepare sql statement at front end only based on the condition. and pass to DB and return the dataset and load...

example:

Private sub SerachDetails(Byval firstname as string,lastname as string,dob as date)
Try
--here you check for all the parameters which are not nothing and based on that write where condition..
catch
End Try
End sub
Imports System.Data.SqlClient

Public Class frmSearchInfo
    Dim conn As New SqlClient.SqlConnection
    Dim SQLdr As SqlDataReader  'The Local Data Store
    Dim cmdSearchChild As New SqlCommand  'The SQL Command
    Dim daSearchChild As New SqlDataAdapter
    Dim dsSearchChild As New DataSet
    Dim dtSearchChild As New DataTable
------------------------------------------------------------------------------------
    Private Sub Form4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        conn.ConnectionString = "Data Source=User-PC;Initial
        Catalog=patientrecords;Integrated Security=True" 'Set the Connection String

        Try
            conn.Open() ' Open db path
            cmdSearchChild.CommandText = "SElECT * FROM Child"

       daSearchChild = New SqlClient.SqlDataAdapter(cmdSearchChild.CommandText, conn)
            daSearchChild.Fill(dsSearchChild, "ChildData")

       Catch ex As Exception

            MessageBox.Show("Failed to connect to data source")
       Finally
            conn.Close()
        End Try
    End Sub
------------------------------------------------------------------------------------
    Private Sub BtnSend_Click(ByVal sender As System.Object, ByVal e  As System.EventArgs) Handles BtnSend.Click

        Dim conn As SqlConnection 'The SQL Connection
        Dim frm As frmUpdate = frmUpdate

        If SFirstName.Text = "" Or SLastName.Text = "" Then
            MsgBox("Please Enter Patient Name", MsgBoxStyle.OkOnly)
        Else
            Try

                Dim myCMD As SqlCommand = New SqlCommand("SELECT * FROM Child WHERE Child_First_Name LIKE '" & Trim(SFirstName.Text) & "'")

                conn = GetConnect()
                conn.Open()

                Dim myReader As SqlDataReader = cmdSearchChild.ExecuteReader

                Dim fNextResult As Boolean = True
                Do Until Not fNextResult
                    Console.WriteLine(vbTab & myReader.GetName(0) & vbTab & myReader.GetName(1))

                    Do While myReader.Read()
                        Console.WriteLine(vbTab & myReader.GetInt32(0) & vbTab & myReader.GetString(1))
                    Loop

                    fNextResult = myReader.NextResult()
                Loop

                myReader.Close()
                conn.Close()

                frm._textBox = _textBox1
                frm._textBox2 = _textBox2
                frm.Show()


            Catch ex As Exception

            End Try
        End If
    
     
    End Sub

-------------------------------------------------------------------------------------
    Private ReadOnly Property _textBox1() As String

        Get
            Return SFirstName.Text
        End Get

    End Property

    Private ReadOnly Property _textBox2() As String

        Get
            Return SLastName.Text
        End Get
    End Property

End Class
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.