Dim check As Integer
Dim conn As SqlConnection
Dim cmdMedical As New SqlCommand
Dim cmdMedical1 As New SqlCommand
Dim daMedical As New SqlDataAdapter
Dim dsMedical As New DataSet
Dim dtMedical As New DataTable
Try
conn = GetConnect() ' this when u call the module to connected....
conn.Open()
cmdMedical = conn.CreateCommand
cmdMedical.CommandText = "SELECT * FROM Medical WHERE Medical_No='" & Trim(txtMedical_No.SelectedItem) & " ' "
daMedical.SelectCommand = cmdMedical
daMedical.Fill(dsMedical, "Medical")
dtMedical = dsMedical.Tables("Medical")
If (dtMedical.Rows.Count > 0) Then
MsgBox("Patient With Medical_No " & Trim(txtMedical_No.Text) & " has been added in data base", MsgBoxStyle.OKOnly, "Message :")
Else
cmdMedical1 = conn.CreateCommand
cmdMedical1.CommandText = "INSERT INTO Medical(IdMedical, Medical_No, BloodType, Disease,BodyAnomaly,Tall,Weight) VALUES('" & Trim(idMedical.Text) & "','" & Trim(txtMedical_No.SelectedItem) & "','" & Trim(cmbBloodType.SelectedItem) & "','" & Trim(txtDisease.Text) & "','" & Trim(txtBodyAnomaly.Text) & "','" & Trim(txtTall.Text) & "','" & Trim(txtWeight.Text) & "')"
check = cmdMedical1.ExecuteReader.RecordsAffected()
If check > 0 Then
MsgBox("Patient With Medical_No " & Trim(txtMedical_No.Text) & " Succesfully Added", MsgBoxStyle.OKOnly, "Message :")
Else
MsgBox("Patient With Medical_No " & Trim(txtMedical_No.Text) & " failed to added", MsgBoxStyle.OKOnly, "Message :")
End If
conn.Close()
End If
Catch ex As Exception
MsgBox("Error: " & ex.Source & ": " & ex.Message, MsgBoxStyle.OKOnly, " Error Connection!!")
End Try
Dim check As Integer
Dim conn As SqlConnection
Dim cmdMedical As New SqlCommand
Dim cmdMedical1 As New SqlCommand
Dim daMedical As New SqlDataAdapter
Dim dsMedical As New DataSet
Dim dtMedical As New DataTable
Try
conn = GetConnect() ' this when u call the module to connected....
conn.Open()
cmdMedical = conn.CreateCommand
cmdMedical.CommandText = "SELECT * FROM Medical WHERE Medical_No='" & Trim(txtMedical_No.SelectedItem) & " ' "
daMedical.SelectCommand = cmdMedical
daMedical.Fill(dsMedical, "Medical")
dtMedical = dsMedical.Tables("Medical")
If (dtMedical.Rows.Count > 0) Then
MsgBox("Patient With Medical_No " & Trim(txtMedical_No.Text) & " has been added in data base", MsgBoxStyle.OKOnly, "Message :")
Else
cmdMedical1 = conn.CreateCommand
cmdMedical1.CommandText = "INSERT INTO Medical(IdMedical, Medical_No, BloodType, Disease,BodyAnomaly,Tall,Weight) VALUES('" & Trim(idMedical.Text) & "','" & Trim(txtMedical_No.SelectedItem) & "','" & Trim(cmbBloodType.SelectedItem) & "','" & Trim(txtDisease.Text) & "','" & Trim(txtBodyAnomaly.Text) & "','" & Trim(txtTall.Text) & "','" & Trim(txtWeight.Text) & "')"
check = cmdMedical1.ExecuteReader.RecordsAffected()
If check > 0 Then
MsgBox("Patient With Medical_No " & Trim(txtMedical_No.Text) & " Succesfully Added", MsgBoxStyle.OKOnly, "Message :")
Else
MsgBox("Patient With Medical_No " & Trim(txtMedical_No.Text) & " failed to added", MsgBoxStyle.OKOnly, "Message :")
End If
conn.Close()
End If
Catch ex As Exception
MsgBox("Error: " & ex.Source & ": " & ex.Message, MsgBoxStyle.OKOnly, " Error Connection!!")
End Try
you can write the update code by your self and post a new thread if you get the problem..ok..all for the best..
Thursday, October 16, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment