Tenho aqui uma form com várias textbox e algumas combobox. O que acontece quando insiro um código e preenche a textbox com data nascimento aparece-me neste formato 01/01/1900 00:00:00
e eu só quero que apareça a data.
Podem ajudar-me? os nomes que aparecem ai como DoctorBasic e DoctorEnterpriseDetails são nomes de tabelas e a DBO é a coluna com as datas de nascimento.
Public Class Form1
Public Sub TxtCodigoMed_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles TxtCodigoMed.KeyPress
If e.KeyChar.ToString = ChrW(Keys.Enter) Then ' Enter para pesquisar
TxtCodigoMed.Focus()
e.Handled = True
CarregarDados()
End If
End Sub
Public Sub CarregarDados()
'LblVazia.Text =
Dim cnnstr As SqlConnection = New SqlConnection("Data Source=****;Initial Catalog=***;user=**;password=****")
Dim myCommand As String
Dim cmd As SqlCommand
Dim da As New System.Data.SqlClient.SqlDataAdapter(cmd)
Dim table = New DataTable
myCommand = "SELECT * FROM DoctorBasic INNER JOIN DoctorEnterpriseDetails ON DoctorBasic.DoctorId = DoctorEnterpriseDetails.DoctorId WHERE EnterpriseId = 26 AND Code = " & TxtCodigoMed.Text
cnnstr.Open()
cmd = New SqlCommand(myCommand, cnnstr)
da.SelectCommand = cmd
da.Fill(table)
TxtPrimeiroNome.Text = table.Rows(0)("FirstName").ToString
TxtApelido.Text = table.Rows(0)("LastName").ToString
TxtNomeComp.Text = table.Rows(0)("FullName").ToString
TxtDataNasc.Text = table.Rows(0)("DOB").ToString
TxtApelido.Text = table.Rows(0)("LastName").ToString
TxtDataForm.Text = table.Rows(0)("GraduateDate").ToString
TxtGrauForm.Text = table.Rows(0)("Degree").ToString
TxtTelefone.Text = table.Rows(0)("Telephone").ToString
TxtTelem.Text = table.Rows(0)("Mobile").ToString
TxtMail.Text = table.Rows(0)("Emailid").ToString
TxtObs.Text = table.Rows(0)("Observation").ToString
TxtLusov.Text = table.Rows(0)("Lusov").ToString
Me.DoctorsAddressTableAdapter.Fill(Me.GSM81DataSet.DoctorsAddress, Me.TxtCodigoMed.Text.ToString) 'carrega a grid através da pesquisa do codigo do médico
cnnstr.Close()
End Sub
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'GSM81DataSet.GroupType' table. You can move, or remove it, as needed.
Me.GroupTypeTableAdapter.Fill(Me.GSM81DataSet.GroupType)
'TODO: This line of code loads data into the 'GSM81DataSet2.Rank' table. You can move, or remove it, as needed.
Me.RankTableAdapter.Fill(Me.GSM81DataSet2.Rank)
'TODO: This line of code loads data into the 'GSM81DataSet1.PrescibingPotential' table. You can move, or remove it, as needed.
Me.PrescibingPotentialTableAdapter.Fill(Me.GSM81DataSet1.PrescibingPotential)
'TODO: This line of code loads data into the 'GSM81DataSet.Speciality' table. You can move, or remove it, as needed.
Me.SpecialityTableAdapter.Fill(Me.GSM81DataSet.Speciality)
End Sub
Public Sub GravarDoctorBasic()
Dim myConnectionString As SqlConnection = New SqlConnection("Data Source=****;Initial Catalog=***;user=**;password=***")
Dim myCommand As String
Dim cmd As SqlCommand
myCommand = "UPDATE DoctorBasic SET " & _
"Lusov = '" & TxtLusov.Text & "', " & _
"FirstName = '" & TxtPrimeiroNome.Text & "', " & _
"LastName = '" & TxtApelido.Text & "', " & _
"FullName = '" & TxtNomeComp.Text & "', " & _
"DOB = " & TxtDataNasc.Text.ToString & ", " & _
"GraduateDate = '" & TxtDataForm.Text.ToString & "', " & _
"Emailid = '" & TxtMail.Text & "', " & _
"Degree = '" & TxtGrauForm.Text & "', " & _
"Observation = '" & TxtObs.Text & "' " & _
"WHERE DoctorId = " & TxtCodigoMed.Text.ToString
cmd = New SqlCommand(myCommand, myConnectionString)
MsgBox(myCommand)
cmd.Connection.Open()
cmd.ExecuteNonQuery()
cmd.Connection.Close()
End Sub
Public Sub GravarDoctorEnterpriseDetails()
Dim myConnectionString As SqlConnection = New SqlConnection("Data Source=****;Initial Catalog=****;user=****;password=*******")
Dim myCommand As String
Dim cmd As SqlCommand
myCommand = "UPDATE DoctorEnterpriseDetails SET " & _
"RankId = " & CBSelec.ValueMember & ", " & _
"GroupId = " & CBCateg.ValueMember & ", " & _
"PrescribingPotential = " & CBPP.ValueMember & ", " & _
"Telephone = " & TxtTelefone.Text & ", " & _
"Mobile = " & TxtTelem.Text & ", " & _
"Speciality1 = " & CBEsp1.ValueMember & ", " & _
"Speciality2 = " & CBEsp2.ValueMember & " " & _
"WHERE DoctorId = " & TxtCodigoMed.Text.ToString
cmd = New SqlCommand(myCommand, myConnectionString)
' MsgBox(myCommand)
cmd.Connection.Open()
cmd.ExecuteNonQuery()
cmd.Connection.Close()
End Sub
Public Sub btnGravar_Click(sender As System.Object, e As System.EventArgs) Handles btnGravar.Click
GravarDoctorBasic()
GravarDoctorEnterpriseDetails()
End Sub
End Class